2. Windows DLL、COM、EXE的发布:版本属性的更新、版本信息在日志中的打印,打印代码参考:
#pragma comment(lib, "version.lib")
char* fileName = "test.dll";
DWORD handle = 0;
DWORD size = GetFileVersionInfoSize(fileName, &handle);
BYTE* versionInfo = new BYTE[size];
if (GetFileVersionInfo(fileName, handle, size, versionInfo))
{
UINT len = 0;
VS_FIXEDFILEINFO* vsfi = NULL;
VerQueryValue(versionInfo, "\\", (void**)&vsfi, &len);
WORD aVersion[4];
aVersion[0] = HIWORD(vsfi->dwFileVersionMS);
aVersion[1] = LOWORD(vsfi->dwFileVersionMS);
aVersion[2] = HIWORD(vsfi->dwFileVersionLS);
aVersion[3] = LOWORD(vsfi->dwFileVersionLS);
XINFO("test.dll version is %d.%d.%d.%d", aVersion[0], aVersion[1], aVersion[2], aVersion[3]);
}
delete[] versionInfo;
3. Windows上安装程序的创建工具:NSIS,示例脚本参考TestServer_microsoft.nsi。
4. Windows DLL的设计:一般包括四个全局函数:Init、Terminate、CreateObject、DestroyObject,和一个接口类:没有成员变量,成员函数都为纯虚函数。 设计目标:动态加载这个DLL时,能够重复地、没有内存泄露地实现LoadLibrary->Init->CreateObject和DestroyObject->Terminate->FreeLibrary。
5. Windows多线程程序的设计:线程的封装,参考代码
6. Windows ActiveX的设计:
7. Windows COM的设计:连接点事件的实现
8. 为64bit的exe封装32bit的dll:
TestInterfaceCom.idl:
[
uuid(BC4127B7-9353-4E7F-B975-01846CA706A1),
version(1.0),
helpstring("TestInterfaceCom 1.0 Type Library" )
]
library TestInterfaceComLib
[
uuid(865D32D9-8A37-4EE5-B4AB-C805893FD312),
helpstring("TestInterfaceObj Class" )
]
coclass TestInterfaceObj
{
[ default] interface ITestInterfaceObj;
[ default, source ] dispinterface _ITestInterfaceObjEvents;
};
HKEY_CLASSES_ROOT\TypeLib\{BC4127B7-9353-4E7F-B975-01846CA706A1}
HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{865D32D9-8A37-4EE5-B4AB-C805893FD312}\LocalServer32
HKEY_CLASSES_ROOT\Wow6432Node\TypeLib\{BC4127B7-9353-4E7F-B975-01846CA706A1}
参考:
1. 《COM技术内幕》