home *** CD-ROM | disk | FTP | other *** search
- /******************************************************************/
- /* */
- /* TurboCAD for Windows */
- /* Copyright (c) 1993 - 2001 */
- /* International Microcomputer Software, Inc. */
- /* (IMSI) */
- /* All rights reserved. */
- /* */
- /******************************************************************/
-
-
- HRESULT GetImsigxPath(LPTSTR lpszPath)
- {
- OLECHAR subKey[_MAX_PATH];
-
- wcscpy(subKey, L"CLSID\\");
- OLECHAR* pGuid = wcschr(subKey, 0);
- if (::StringFromGUID2(CLSID_XApplication, pGuid, _MAX_PATH) == 0)
- return E_FAIL;
- wcscat(subKey, L"\\InProcServer32");
-
- HKEY hKey;
- if (::RegOpenKeyExW(
- HKEY_CLASSES_ROOT, // handle of open key
- subKey, // address of name of subkey to open
- 0, // reserved
- KEY_READ, // security access mask
- &hKey) // address of handle of open key
- != ERROR_SUCCESS)
- return E_FAIL;
-
- DWORD dwType;
- DWORD dwData;
- LONG lResult = ::RegQueryValueEx(
- hKey, // handle of key to query
- NULL, // address of name of value to query
- NULL, // reserved
- &dwType, // address of buffer for value type
- (LPBYTE)lpszPath, // address of data buffer
- &dwData); // address of data buffer size
-
- ::RegCloseKey(hKey);
- return (lResult == ERROR_SUCCESS) ? S_OK : E_FAIL;
- }
-
- void CMakeDwgDlg::OnInprocServer()
- {
- TCHAR szIMSIGXDLL[_MAX_PATH];
- HRESULT hRes = GetImsigxPath(szIMSIGXDLL);
- if (SUCCEEDED(hRes))
- {
- hRes = E_FAIL;
- HINSTANCE hMod = ::LoadLibrary(szIMSIGXDLL);
- if (hMod != NULL)
- {
- HRESULT (*GetApp)(IApplication**) =
- (HRESULT (*)(IApplication**))
- ::GetProcAddress(hMod, "IMSIGXGetXApplication");
- if (GetApp != NULL)
- hRes = (*GetApp)(&m_pIApplication);
- // ::FreeLibrary(szIMSIGXDLL);
- }
- else
- {
- DWORD dwLastError = GetLastError();
- hRes = E_FAIL;
- }
- }
-
- if (FAILED(hRes))
- {
- AfxMessageBox("Couldn't create application object (in-process server)!");
- }
-
- EnableButtons();
- }
-
-