我用 nmake -f makefile 编译是在cmpnt.cpp的312行出了一个类型转换错误,用命令行:cl/LD cmpnt.cpp guid.cpp uuid.lib guid.def来编译也是一样,百思不得其解,痛苦!
   清高手们指点!!!!!!!!!!!!!

解决方案 »

  1.   

    我的方法是将DLLMain函数中的第一个函数参数的类型HANDEL改为HINSTANCE,就可以了,你试一试。以后的几章我都是这样改的。
    另外,以后几章中我将register.bat中的regsvr32 -s cmpnt.dll改为了regsvr32 cmpnt.dll,这样可以看到操作结果提示,另新建了一个uregister.bat,其中内容与register.bat基本一样,但是命令为regsvr32 -u cmpnt.dll,这样可以完成从注册表中卸载组建dll。
    这两个操作其实就是调用dll中的dllregisterserver和dllunregisterserver函数(函数名可能记错了,另外大小写省略,大家明白意思)。
      

  2.   

    #ifndef __Registry_H__
    #define __Registry_H__
    //
    // Registry.h
    //   - Helper functions registering and unregistering a component.
    //// This function will register a component in the Registry.
    // The component calls this function from its DllRegisterServer function.
    HRESULT RegisterServer(HMODULE hModule, 
                           const CLSID& clsid, 
                           const char* szFriendlyName,
                           const char* szVerIndProgID,
                           const char* szProgID) ;// This function will unregister a component.  Components
    // call this function from their DllUnregisterServer function.
    HRESULT UnregisterServer(const CLSID& clsid,
                             const char* szVerIndProgID,
                             const char* szProgID) ;#endif