卸载类型库的API及用法
时间: 2023-12-09 22:05:27 浏览: 25
卸载类型库的API是 `UnRegisterTypeLib`。该函数的声明如下:
```c++
HRESULT UnRegisterTypeLib(
REFGUID rguid,
WORD wVerMajor,
WORD wVerMinor,
LCID lcid,
SYSKIND syskind
);
```
参数说明:
- `rguid`:类型库的唯一标识符。
- `wVerMajor`:类型库的主版本号。
- `wVerMinor`:类型库的次版本号。
- `lcid`:类型库的区域设置标识符。
- `syskind`:操作系统类型。
调用该函数即可卸载指定的类型库。示例代码:
```c++
#include <Windows.h>
#include <tchar.h>
int _tmain(int argc, _TCHAR* argv[])
{
HRESULT hr = S_OK;
GUID guid = { 0x12345678, 0x1234, 0x1234, { 0x12, 0x34, 0x12, 0x34, 0x12, 0x34, 0x12, 0x34 } };
hr = UnRegisterTypeLib(guid, 1, 0, MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT), SYS_WIN32);
if (SUCCEEDED(hr))
{
_tprintf(_T("Unregister type library succeeded!\n"));
}
else
{
_tprintf(_T("Unregister type library failed with error code 0x%x!\n"), hr);
}
return 0;
}
```
注意:在调用 `UnRegisterTypeLib` 函数之前,必须先确保类型库没有被引用,否则卸载会失败。