Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here's a C++ version I just had to write. Taken directly from ICR's C# version.</p> <pre><code>void PrintString(CString string) { std::wcout &lt;&lt; static_cast&lt;LPCTSTR&gt;(string) &lt;&lt; endl; } CString GetClassesRootKeyValue(const wchar_t * keyName) { HKEY hkey; TCHAR keyNameCopy[256] = {0}; _tcscpy_s(keyNameCopy, 256, keyName); BOOL bResult = SUCCEEDED(::RegOpenKey(HKEY_CLASSES_ROOT, keyNameCopy, &amp;hkey)); CString hkeyValue = CString(""); if (bResult) { TCHAR temporaryValueBuffer[256]; DWORD bufferSize = sizeof (temporaryValueBuffer); DWORD type; bResult = SUCCEEDED(RegQueryValueEx(hkey, _T(""), NULL, &amp;type, (BYTE*)temporaryValueBuffer, &amp;bufferSize)) &amp;&amp; (bufferSize &gt; 1); if (bResult) { hkeyValue = CString(temporaryValueBuffer); } RegCloseKey(hkey); return hkeyValue; } return hkeyValue; } int _tmain(int argc, TCHAR* argv[], TCHAR* envp[]) { int nRetCode = 0; // initialize MFC and print and error on failure if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0)) { // TODO: change error code to suit your needs _tprintf(_T("Fatal Error: MFC initialization failed\n")); nRetCode = 1; } else { CString dwgAppName = GetClassesRootKeyValue(_T(".dwg")); PrintString(dwgAppName); dwgAppName.Append(_T("\\shell\\open\\command")); PrintString(dwgAppName); CString trueViewOpenCommand = GetClassesRootKeyValue(static_cast&lt;LPCTSTR&gt;(dwgAppName)); PrintString(trueViewOpenCommand); // Shell open command usually ends with a "%1" for commandline params. We don't want that, // so strip it off. int firstParameterIndex = trueViewOpenCommand.Find(_T("%")); PrintString(trueViewOpenCommand.Left(firstParameterIndex).TrimRight('"').TrimRight(' ')); cout &lt;&lt; "\n\nPress &lt;enter&gt; to exit..."; getchar(); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload