Debian Codegraph @

Contrib/Library/TypeLib/TypeLib.cpp

raw
1 /*
2
3 NSIS plug-in for Type Library Registration/UnRegistration
4 Written by Joost Verburg
5
6 Unicode support by Jim Park -- 08/23/2007
7
8 */
9
10 #include <windows.h>
11 #include <nsis/pluginapi.h> // nsis plugin
12 #include <nsis/nsis_tchar.h>
13
14 #define NSISFunction(funcname) extern "C" void __declspec(dllexport) funcname(HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop)
15
16 extern "C" BOOL WINAPI DllMain(HINSTANCE hInst, ULONG ul_reason_for_call, LPVOID lpReserved) {
17 return TRUE;
18 }
19
20 NSISFunction(Register) {
21
22 EXDLL_INIT();
23
24 wchar_t ole_filename[1024];
25 PopStringW(ole_filename);
26
27 ITypeLib* typeLib;
28 HRESULT hr;
29
30 hr = LoadTypeLib(ole_filename, &typeLib);
31
32 if (SUCCEEDED(hr)) {
33
34 RegisterTypeLib(typeLib, ole_filename, NULL);
35
36 hr = typeLib->Release();
37
38 }
39
40 }
41
42 NSISFunction(UnRegister) {
43
44 EXDLL_INIT();
45
46 wchar_t ole_filename[1024];
47 PopStringW(ole_filename);
48
49 ITypeLib* typeLib;
50 HRESULT hr;
51
52 hr = LoadTypeLibEx(ole_filename, REGKIND_NONE, &typeLib);
53
54 if (SUCCEEDED(hr))
55 {
56
57 TLIBATTR* typelibAttr;
58
59 hr = typeLib->GetLibAttr(&typelibAttr);
60
61 if(SUCCEEDED(hr))
62 {
63
64 UnRegisterTypeLib(typelibAttr->guid,
65 typelibAttr->wMajorVerNum,
66 typelibAttr->wMinorVerNum,
67 typelibAttr->lcid,
68 typelibAttr->syskind);
69
70 typeLib->ReleaseTLibAttr(typelibAttr);
71
72 }
73
74 typeLib->Release();
75
76 }
77
78 }
79
80 NSISFunction(GetLibVersion) {
81
82 EXDLL_INIT();
83
84 wchar_t ole_filename[1024];
85 PopStringW(ole_filename);
86
87 ITypeLib* typeLib;
88 HRESULT hr;
89
90 hr = LoadTypeLib(ole_filename, &typeLib);
91
92 if (SUCCEEDED(hr))
93 {
94
95 TLIBATTR* typelibAttr;
96
97 hr = typeLib->GetLibAttr(&typelibAttr);
98
99 if (SUCCEEDED(hr))
100 {
101
102 TCHAR buf[33];
103
104 wsprintf(buf, _T("%d"), typelibAttr->wMajorVerNum);
105 pushstring(buf);
106 wsprintf(buf, _T("%d"), typelibAttr->wMinorVerNum);
107 pushstring(buf);
108
109 typeLib->ReleaseTLibAttr(typelibAttr);
110
111 }
112 else
113 {
114 pushstring(_T("0"));
115 pushstring(_T("0"));
116 }
117
118 typeLib->Release();
119
120 }
121 else
122 {
123 pushstring(_T("0"));
124 pushstring(_T("0"));
125 }
126
127 }