C++Builder Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
C++빌더 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
메신저 프로젝트
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
볼랜드포럼 광고 모집

C++빌더 팁&트릭
C++Builder Programming Tip&Tricks
[1156] Win64 에서 Win32 COM 호출방법
둘리.CSIEDA [dooly386] 8597 읽음    2014-07-22 08:07
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();
    }
---------------------------------------------------------------------------------------------------------

감사 합니다.
아르페지오 [towcow]   2014-07-28 13:24 X
좋은정보 감사합니다.

+ -

관련 글 리스트
1156 Win64 에서 Win32 COM 호출방법 둘리.CSIEDA 8597 2014/07/22
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.