Win64 application 에서 Win32 모듈을 호출할 일이 있어서 여러가지(IPC를 주로 했음) 방법을 찾아 사용했는데
마침 아래와 같은 트릭이 있더군요.
저같은경우 JNI 가 32bit 모듈이라...(혹시 JNI가 64bit 모듈이 있나요???? 있으면 정보좀 부탁드려요)
win64 app에서 win32 COM을 사용하려니 "클래스가 등록되지 않았습니다" 어쩌구 하고 메시지를 뱉어 버리더군요.. 당연하겠지만..
흥미롭기도 해서 올립니다.
이것은 정확한 논리가 아니라 트릭 입니다. 일단 잘 돌더군요... 참고하세요.
일단 자신의 COM module을 regsvr32 로 등록해주신후 하세요..
원문은 :
http://www.codeproject.com/Tips/267554/Using-bit-COM-Object-from-bit-Application
방법은 아래와 같음 (굳이 해석은 하지 않겠습니다)
Using a 32-bit COM Object from a 64-bit Application
By modifying the Registry, you can allow a 64-bit app to use a 32-bit COM object.
1. Locate your COM object GUID under HKey_Classes_Root/Wow6432Node/CLSID.
2. Once located, add a new REG_SZ (string) value. The name should be AppID and the data should be the same COM object GUID you have just searched for.
3. Add a new key under HKey_Classes_Root/Wow6432Node/AppID. The new key should be called the same as the COM object GUID.
4. Under the new key you just added, add a new REG_SZ (string) value, and call it DllSurrogate. Leave the value empty.
5. Create a new key under HKey_Local_Machine/Software/Classes/AppID, if it doesn't already exist. Again, the new key should be called the same as the COM object's GUID. No values are necessary to be added under this key.
---------------------------------------------------------------------------------------------------------
아래에는 위의 방법대로 코딩한것 입니다. regedit 로 일일이 찾아서 하기가 까다롭더군요..
OpenKey 등 성공실패 검증은 각자 넣어주시면 더 안전하겠지요?
UnicodeString ComObjectGUID = InputCOMObjectGUID->Text; << 이곳은 자신의 COM object guid를 넣어 주세요.
TRegistry* reg = new TRegistry(KEY_READ);
reg->RootKey = HKEY_CLASSES_ROOT;
UnicodeString path1 = "Wow6432Node\\CLSID\\";
UnicodeString path2 = "Wow6432Node\\AppID\\";
if(reg->KeyExists(path1+ComObjectGUID))
{
reg->Access = KEY_WRITE;
reg->OpenKey(path1+ComObjectGUID,true);
reg->WriteString("AppID",ComObjectGUID);
reg->CloseKey();
reg->OpenKey(path2+ComObjectGUID,true);
reg->WriteString("DllSurrogate","");
reg->CloseKey();
reg->RootKey = HKEY_LOCAL_MACHINE;
reg->OpenKey(UnicodeString("Software\\Classes\\AppID\\")+ComObjectGUID,true);
reg->CloseKey();
}
---------------------------------------------------------------------------------------------------------
감사 합니다.