2 * COPYRIGHT: See COPYING in the top level directory
4 * FILE: apps\regsvr32\regsvr32.c
5 * PURPOSE: Register a COM component in the registry
6 * PROGRAMMER: jurgen van gael [jurgen.vangael@student.kuleuven.ac.be]
10 /********************************************************************
13 This library is free software; you can redistribute it and/or
14 modify it under the terms of the GNU Library General Public License as
15 published by the Free Software Foundation; either version 2 of the
16 License, or (at your option) any later version.
18 This library is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 Library General Public License for more details.
23 You should have received a copy of the GNU Library General Public
24 License along with this library; see the file COPYING.LIB. If
25 not, write to the Free Software Foundation, Inc., 675 Mass Ave,
26 Cambridge, MA 02139, USA.
29 ********************************************************************/
31 // regsvr32 [/u] [/s] [/n] [/i[:cmdline]] dllname
32 // [/u] unregister server
33 // [/s] silent (no message boxes)
34 // [/i] Call DllInstall passing it an optional [cmdline]; when used with /u calls dll uninstall
35 // [/n] Do not call DllRegisterServer; this option must be used with [/i]
41 typedef HRESULT (*DLLREGISTER
) (void);
42 typedef HRESULT (*DLLUNREGISTER
) (void);
48 printf("regsvr32 [/u] [/s] [/n] [/i[:cmdline]] dllname\n");
49 printf("\t[/u] unregister server\n");
50 printf("\t[/s] silent (no message boxes)\n");
51 printf("\t[/i] Call DllInstall passing it an optional [cmdline]; when used with /u calls dll uninstall\n");
52 printf("\t[/n] Do not call DllRegisterServer; this option must be used with [/i]\n");
57 int RegisterDll(char* strDll
)
60 DLLREGISTER pfRegister
;
61 HMODULE DllHandle
= NULL
;
63 DllHandle
= LoadLibrary(strDll
);
67 printf("Dll not found\n");
71 pfRegister
= (VOID
*) GetProcAddress(DllHandle
, "DllRegisterServer");
75 printf("DllRegisterServer not implemented\n");
83 printf("Failed to register dll\n");
88 printf("Succesfully registered dll\n");
92 FreeLibrary(DllHandle
);
95 int UnregisterDll(char* strDll
)
98 HMODULE DllHandle
= NULL
;
99 DLLUNREGISTER pfUnregister
;
101 DllHandle
= LoadLibrary(strDll
);
105 printf("Dll not found\n");
109 pfUnregister
= (VOID
*) GetProcAddress(DllHandle
, "DllUnregisterServer");
113 printf("DllUnregisterServer not implemented\n");
121 printf("Failed to unregister dll\n");
126 printf("Succesfully unregistered dll\n");
130 FreeLibrary(DllHandle
);
133 int main(int argc
, char* argv
[])
137 char DllName
[MAX_PATH
];
141 for(i
= 0; i
< argc
; i
++)
143 if(argv
[i
][0] == '/')
145 if(argv
[i
][1] == 'u')
147 else if(argv
[i
][1] == 's')
149 else if(argv
[i
][1] == 'i')
150 ; // not implemented yet
151 else if(argv
[i
][1] == 'n')
152 ; // not implemented yet
155 strcpy(DllName
, argv
[i
]);
158 if(!strcmp(DllName
, "regsvr32") || !strcmp(DllName
, "regsvr32.exe"))
167 return RegisterDll(DllName
);
169 return UnregisterDll(DllName
);