none
Class not register on Windows 7 64 bit

    Question

  • ======================================================================================================================

    ATL Project

    1.start Visual Studio 2012 as administrator

    2.New ATL project,name: xssfj

    3.Open class view,New Class,ATL simple object,name:TextTool

    4.Chose ITextTool,add method,input "Reg2CmdForDelete",add 2 parameter:LPCTSTR registryFilePath and LPCTSTR batchFilePath

    5.Build,success.

    ======================================================================================================================

    Win32 Project

    1.New Win32 Project,empty project,name:xssm

    2.Add new item:main.cpp,insert basic win32 code in Visual Assistant X

    3.Copy xssfj.tlb to folder of this project

    4.Add exists item,add xssfj.tlb to this project

    5.main.cpp,at file header,insert code: 

    #import "xssfj.tlb" no_auto_exclude

    6.add one menu,on message,call method:DisposalWmCommand.the method code is:
    	CoInitialize(NULL);
    	try
    	{
    		xssfjLib::ITextToolPtr p(__uuidof(xssfjLib::ITextTool));
    		p->Reg2CmdForDelete(L"",L"");
    	}
    	catch(_com_error e)
    	{
    		MessageBox(NULL,e.ErrorMessage(),TEXT("error message"),MB_OK);
    	}
    	CoUninitialize();

    Results are always prompt "Class not registered", I checked the registry and see that it is already registered. I in Windows XP and Windows 7, 32-bit environment has not come across this problem, and I am using Visual C++ 6.0, using the same steps in Windows 7 64-bit environment is also no problem, I've found when comparing the registry using Visual C++ 6.0 ATL programming components registered under the HKCR\CLSID, VS2012 ATL component registered with the HKCR\Wow6432Node\ Under the CLSID. I have looked for Registry information Direct, arguably, regardless of registration where there is no problem. Now is actually a problem.

    Please help me, how to solve the "Class not registered" problem, thank you!


    zhuangtaiqiusi

    Sunday, June 29, 2014 3:33 PM

Answers

  • The parameter to the constructor for xssfjLib::ITextToolPtr must be the CLSID, not the IID.

    Change it to:

    xssfjLib::ITextToolPtr p(__uuidof(xssfjLib::TextTool));
    

    I also note that you defined your parameters as of type LPCTSTR. You will find that only one byte will be transferred if you are crossing apartment boundaries. You should change the parameter to type BSTR.

    • Marked as answer by 妆台秋思 Monday, June 30, 2014 2:18 AM
    Sunday, June 29, 2014 6:13 PM

All replies

  • The parameter to the constructor for xssfjLib::ITextToolPtr must be the CLSID, not the IID.

    Change it to:

    xssfjLib::ITextToolPtr p(__uuidof(xssfjLib::TextTool));
    

    I also note that you defined your parameters as of type LPCTSTR. You will find that only one byte will be transferred if you are crossing apartment boundaries. You should change the parameter to type BSTR.

    • Marked as answer by 妆台秋思 Monday, June 30, 2014 2:18 AM
    Sunday, June 29, 2014 6:13 PM
  • Oh my god! low-level error!I had put LPTSTR into BSTR.

    Thank you very much!!!


    zhuangtaiqiusi


    Monday, June 30, 2014 2:20 AM