Used to register and unregister typelib in the registry. Usage: You can use regtypelib.exe /? View help. 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}
The source code is as follows:# Include<Windows. h>
# Include<Stdio. h>
void showerrormessage ();
void showusage ();
int wmain ( int argc, wchar * argv [])
{< br> If (argc 2 )
{< br> showerrormessage ();
return 1 ;< BR >}
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 ' ? ' )
{< br> showusage ();
return 0 ;< BR >}
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;
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;
}
VoidShowerrormessage ()
{
Wprintf (L"The syntax of the command is incorrect. \ r \ n");
Showusage ();
}
Void Showusage ()
{
Wprintf (L " Regtypelib V1.0 (c) Zhenxing Zhou \ 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 " );
}
Download: Download the source file and Executable File