惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 叶小钗
云风的 BLOG
云风的 BLOG
G
Google Developers Blog
S
SegmentFault 最新的问题
罗磊的独立博客
Hugging Face - Blog
Hugging Face - Blog
美团技术团队
爱范儿
爱范儿
博客园 - 三生石上(FineUI控件)
H
Hackread – Cybersecurity News, Data Breaches, AI and More
D
DataBreaches.Net
F
Fortinet All Blogs
TaoSecurity Blog
TaoSecurity Blog
D
Docker
C
Cybersecurity and Infrastructure Security Agency CISA
K
Kaspersky official blog
宝玉的分享
宝玉的分享
腾讯CDC
Google Online Security Blog
Google Online Security Blog
Recorded Future
Recorded Future
T
The Exploit Database - CXSecurity.com
T
The Blog of Author Tim Ferriss
V
V2EX
S
Securelist
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
C
CERT Recently Published Vulnerability Notes
A
Arctic Wolf
Scott Helme
Scott Helme
L
LINUX DO - 热门话题
Y
Y Combinator Blog
P
Proofpoint News Feed
T
Tor Project blog
AWS News Blog
AWS News Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
The Last Watchdog
The Last Watchdog
博客园 - 聂微东
T
Threat Research - Cisco Blogs
B
Blog
Attack and Defense Labs
Attack and Defense Labs
L
Lohrmann on Cybersecurity
C
CXSECURITY Database RSS Feed - CXSecurity.com
阮一峰的网络日志
阮一峰的网络日志
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
IT之家
IT之家
N
News and Events Feed by Topic
博客园 - 司徒正美
H
Help Net Security
C
Cisco Blogs
C
Check Point Blog
S
Secure Thoughts

博客园 - Zzx飘遥

【软件发布】发布一个查单词的小工具 COM 入门(4) COM 入门(3) COM 入门(2) COM 入门(1) C#内嵌汇编代码的讨论 仿Win7显示桌面的工具 Deep Zoom Composer初探 ASP.NET VirtualPathProvider (下) Silverlight3离线运行 [译]理解Windows消息循环 WPF BitmapImage与byte[]的转换 VC++中启用XP主题外观 C#4.0初探:dynamic 关键字 - Zzx飘遥 - 博客园 四个字节整型转换为IP格式 - Zzx飘遥 - 博客园 拯救开启桌面效果后白屏的openSUSE 遭遇SqlDataReader锁定表 软件更新:网页设计师必备 之 网站截图工具 (附源码) C#4.0初探: Optional and named parameters
发布一个注册类型库(TypeLib)的小工具
Zzx飘遥 · 2010-09-23 · via 博客园 - Zzx飘遥

用于在注册表中注册和反注册TypeLib。使用方法:可以用RegTypeLib.exe /? 查看帮助。

RegTypeLib v1.0 (c) Zhenxing Zhou

A tool to register TypeLib or unregister TypeLib
Using RegTypeLib.exe /? to show help
Using RegTypeLib.exe /r <TypeLib file path> to register TypeLib
Using RegTypeLib.exe /u <TypeLib guid> to unregister TypeLib
Example:
        RegTypeLib.exe /r D:\a.tlb
        RegTypeLib.exe /u {bb6df56e-cace-11dc-9992-0019b93a3a84}

源码如下:

#include <Windows.h>
#include
<stdio.h> void ShowErrorMessage();
void ShowUsage(); int wmain(int argc, WCHAR* argv[])
{
    
if(argc < 2)
    {
        ShowErrorMessage();
        
return 1;
    }
if(wcslen(argv[1]) != 2)
    {
        ShowErrorMessage();
        
return 1;
    }
if(argv[1][0] != L'/' && argv[1][0] != L'-')
    {
        ShowErrorMessage();
        
return 1;
    }
if(argv[1][1] == L'?')
    {
        ShowUsage();
        
return 0;
    }
if(argc < 3)
    {
        ShowErrorMessage();
        
return 1;
    }
if(tolower(argv[1][1]) == L'r')
    {
        HANDLE hFile
= CreateFile(argv[2], 0, 0, NULL, OPEN_EXISTING, 0, NULL); if(hFile == INVALID_HANDLE_VALUE)
        {
            wprintf(L
"The file %s does not exists!\r\n", argv[2]);
            
return 1;
        }

        CloseHandle(hFile);

        HRESULT hr

= S_OK;
        ITypeLib
*pTypeLib;
        
        hr
= LoadTypeLibEx(argv[2], REGKIND_REGISTER, &pTypeLib); if(FAILED(hr))
        {
            wprintf(L
"Register TypeLib failed. Error Code: %lu", hr);
            
return 1;
        }
        
else
        {
            wprintf(L
"Register TypeLib succeed.");
            pTypeLib
->Release();
        }
    }
    
else if(tolower(argv[1][1]) == L'u')
    {
        HRESULT hr
= S_OK;
        GUID guid;

        hr

= CLSIDFromString(argv[2], &guid); if(FAILED(hr))
        {
            wprintf(L
"Can't convert %s to GUID. Error Code: %lu", argv[2], hr);
        }
        
else
        {
            hr
= UnRegisterTypeLib(guid, 1, 0, LANG_NEUTRAL, SYS_WIN32); if(FAILED(hr))
            {
                wprintf(L
"Can't unregister the TypeLib. Error Code: %lu", hr);
                
return 1;
            }
            
else
            {
                wprintf(L
"Unregister TypeLib %s successfully.", argv[2]);
            }
        }
    }
    
else
    {
        ShowErrorMessage();
        
return 1;
    }
return 0;
}
void ShowErrorMessage()
{
    wprintf(L
"The syntax of the command is incorrect.\r\n\r\n");

    ShowUsage();
}

void ShowUsage()
{
    wprintf(L
"RegTypeLib v1.0 (c) Zhenxing Zhou\r\n\r\n");
    wprintf(L
"A tool to register TypeLib or unregister TypeLib\r\n");
    wprintf(L
"Using RegTypeLib.exe /? to show help\r\n");
    wprintf(L
"Using RegTypeLib.exe /r <TypeLib file path> to register TypeLib\r\n");
    wprintf(L
"Using RegTypeLib.exe /u <TypeLib guid> to unregister TypeLib\r\n");
    wprintf(L
"Example:\r\n");
    wprintf(L
"\tRegTypeLib.exe /r D:\\a.tlb\r\n");
    wprintf(L
"\tRegTypeLib.exe /u {bb6df56e-cace-11dc-9992-0019b93a3a84}\r\n");
}

下载:下载源文件及可执行文件