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