Fixed the Win16/Win32 structure size/alignment differences of
[wine] / dlls / oleaut32 / oleaut.c
1 /*
2  *      OLEAUT32
3  *
4  */
5 #include <string.h>
6 #include "windef.h"
7 #include "wingdi.h"
8 #include "winuser.h"
9 #include "winerror.h"
10 #include "winversion.h"
11
12 #include "heap.h"
13 #include "ldt.h"
14 #include "debugtools.h"
15
16 #include "initguid.h"
17 #include "oleauto.h"
18 #include "olectl.h"
19
20 DEFAULT_DEBUG_CHANNEL(ole);
21
22 static WCHAR    _delimiter[2] = {'!',0}; /* default delimiter apparently */
23 static WCHAR    *pdelimiter = &_delimiter[0];
24
25 /***********************************************************************
26  *              RegisterActiveObject
27  */
28 HRESULT WINAPI RegisterActiveObject(
29         LPUNKNOWN punk,REFCLSID rcid,DWORD dwFlags,LPDWORD pdwRegister
30 ) {
31         WCHAR                   guidbuf[80];
32         HRESULT                 ret;
33         LPRUNNINGOBJECTTABLE    runobtable;
34         LPMONIKER               moniker;
35
36         StringFromGUID2(rcid,guidbuf,39);
37         ret = CreateItemMoniker(pdelimiter,guidbuf,&moniker);
38         if (FAILED(ret)) 
39                 return ret;
40         ret = GetRunningObjectTable(0,&runobtable);
41         if (FAILED(ret)) {
42                 IMoniker_Release(moniker);
43                 return ret;
44         }
45         ret = IRunningObjectTable_Register(runobtable,dwFlags,punk,moniker,pdwRegister);
46         IRunningObjectTable_Release(runobtable);
47         IMoniker_Release(moniker);
48         return ret;
49 }
50
51 /***********************************************************************
52  *              RevokeActiveObject
53  */
54 HRESULT WINAPI RevokeActiveObject(DWORD xregister,LPVOID reserved)
55 {
56         LPRUNNINGOBJECTTABLE    runobtable;
57         HRESULT                 ret;
58
59         ret = GetRunningObjectTable(0,&runobtable);
60         if (FAILED(ret)) return ret;
61         ret = IRunningObjectTable_Revoke(runobtable,xregister);
62         if (SUCCEEDED(ret)) ret = S_OK;
63         IRunningObjectTable_Release(runobtable);
64         return ret;
65 }
66
67 /***********************************************************************
68  *              GetActiveObject
69  */
70 HRESULT WINAPI GetActiveObject(REFCLSID rcid,LPVOID preserved,LPUNKNOWN *ppunk)
71 {
72         WCHAR                   guidbuf[80];
73         HRESULT                 ret;
74         LPRUNNINGOBJECTTABLE    runobtable;
75         LPMONIKER               moniker;
76
77         StringFromGUID2(rcid,guidbuf,39);
78         ret = CreateItemMoniker(pdelimiter,guidbuf,&moniker);
79         if (FAILED(ret)) 
80                 return ret;
81         ret = GetRunningObjectTable(0,&runobtable);
82         if (FAILED(ret)) {
83                 IMoniker_Release(moniker);
84                 return ret;
85         }
86         ret = IRunningObjectTable_GetObject(runobtable,moniker,ppunk);
87         IRunningObjectTable_Release(runobtable);
88         IMoniker_Release(moniker);
89         return ret;
90 }
91
92 /***********************************************************************
93  *           OaBuildVersion           [OLEAUT32.170]
94  *
95  * known OLEAUT32.DLL versions:
96  * OLE 2.1  NT                          1993-95 10     3023
97  * OLE 2.1                                      10     3027
98  * OLE 2.20 W95/NT                      1993-96 20     4112
99  * OLE 2.20 W95/NT                      1993-96 20     4118
100  * OLE 2.20 W95/NT                      1993-96 20     4122
101  * OLE 2.30 W95/NT                      1993-98 30     4265
102  * OLE 2.40 NT??                        1993-98 40     4267
103  * OLE 2.40 W98 SE orig. file           1993-98 40     4275
104  */
105 UINT WINAPI OaBuildVersion()
106 {
107     FIXME("Please report to a.mohr@mailto.de if you get version error messages !\n");
108     switch(VERSION_GetVersion())
109     {
110         case WIN31:
111                 return MAKELONG(4049, 20); /* from Win32s 1.1e */
112         case WIN95:
113                 return MAKELONG(4265, 30);
114         case WIN98:
115                 return MAKELONG(4275, 40); /* value of W98 SE; orig. W98 AFAIK has 4265, 30 just as W95 */
116         case NT351:
117                 return MAKELONG(4265, 30); /* value borrowed from Win95 */
118         case NT40:
119                 return MAKELONG(4122, 20); /* ouch ! Quite old, I guess */
120         default:
121                 ERR("Version value not known yet. Please investigate it !\n");
122                 return 0x0;
123     }
124 }
125
126 /***********************************************************************
127  *              DllRegisterServer
128  */
129 HRESULT WINAPI OLEAUT32_DllRegisterServer() { 
130     FIXME("stub!\n");
131     return S_OK;
132 }
133
134 /***********************************************************************
135  *              DllUnregisterServer
136  */
137 HRESULT WINAPI OLEAUT32_DllUnregisterServer() {
138     FIXME("stub!\n");
139     return S_OK;
140 }