regtlb.cpp
上传用户:bjlvip
上传日期:2010-02-08
资源大小:744k
文件大小:1k
- // regtlb.cpp
- #define _WIN32_DCOM
- #include <windows.h>
- #include <iostream.h>
- void main(int argc, char** argv)
- {
- if(argc < 2)
- {
- cout << "Usage: regtlb tlbfile.tlb" << endl;
- return;
- }
- CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
- OLECHAR psz[MAX_PATH];
- mbstowcs(psz, argv[1], sizeof(psz));
- // MultiByteToWideChar(CP_ACP, 0, argv[1], strlen(argv[1]), psz, 255);
- ITypeLib* pTypeLib;
- HRESULT hr = LoadTypeLibEx(psz, REGKIND_REGISTER, &pTypeLib);
- if(FAILED(hr))
- {
- cout << "LoadTypeLibEx failed" << endl;
- return;
- }
- else
- cout << "Type library registered" << endl;
- pTypeLib->Release();
- CoUninitialize();
- }