Added a missing prototype.
[wine/wine-kai.git] / dlls / ole32 / ole32_main.c
blob017a71683468a82614aff5f3fa77ee6f0406712f
1 /*
2 * OLE32 Initialization
4 * Copyright 2000 Huw D M Davies for CodeWeavers
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include <stdarg.h>
22 #include <stdio.h>
24 #include "windef.h"
25 #include "winerror.h"
26 #include "winbase.h"
27 #include "wingdi.h"
28 #include "winuser.h"
29 #include "winnls.h"
30 #include "ole32_main.h"
31 #include "wine/debug.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(ole);
35 HINSTANCE OLE32_hInstance = 0;
37 /***********************************************************************
38 * OleMetafilePictFromIconAndLabel (OLE32.@)
40 HGLOBAL WINAPI OleMetafilePictFromIconAndLabel(HICON hIcon, LPOLESTR lpszLabel,
41 LPOLESTR lpszSourceFile, UINT iIconIndex)
43 METAFILEPICT mfp;
44 HDC hdc;
45 UINT dy;
46 HGLOBAL hmem = NULL;
47 LPVOID mfdata;
48 static const char szIconOnly[] = "IconOnly";
50 TRACE("%p %p %s %d\n", hIcon, lpszLabel, debugstr_w(lpszSourceFile), iIconIndex);
52 if( !hIcon )
53 return NULL;
55 hdc = CreateMetaFileW(NULL);
56 if( !hdc )
57 return NULL;
59 ExtEscape(hdc, MFCOMMENT, sizeof(szIconOnly), szIconOnly, 0, NULL);
61 /* FIXME: things are drawn in the wrong place */
62 DrawIcon(hdc, 0, 0, hIcon);
63 dy = GetSystemMetrics(SM_CXICON);
64 if(lpszLabel)
65 TextOutW(hdc, 0, dy, lpszLabel, lstrlenW(lpszLabel));
67 if (lpszSourceFile)
69 char szIconIndex[10];
70 int path_length = WideCharToMultiByte(CP_ACP,0,lpszSourceFile,-1,NULL,0,NULL,NULL);
71 if (path_length > 1)
73 char * szPath = CoTaskMemAlloc(path_length * sizeof(CHAR));
74 if (szPath)
76 WideCharToMultiByte(CP_ACP,0,lpszSourceFile,-1,szPath,path_length,NULL,NULL);
77 ExtEscape(hdc, MFCOMMENT, path_length, szPath, 0, NULL);
78 CoTaskMemFree(szPath);
81 snprintf(szIconIndex, 10, "%u", iIconIndex);
82 ExtEscape(hdc, MFCOMMENT, strlen(szIconIndex)+1, szIconIndex, 0, NULL);
85 mfp.mm = MM_ISOTROPIC;
86 mfp.xExt = mfp.yExt = 0; /* FIXME ? */
87 mfp.hMF = CloseMetaFile(hdc);
88 if( !mfp.hMF )
89 return NULL;
91 hmem = GlobalAlloc( GMEM_MOVEABLE, sizeof(mfp) );
92 if( !hmem )
94 DeleteMetaFile(mfp.hMF);
95 return NULL;
98 mfdata = GlobalLock( hmem );
99 if( !mfdata )
101 GlobalFree( hmem );
102 DeleteMetaFile(mfp.hMF);
103 return NULL;
106 memcpy(mfdata,&mfp,sizeof(mfp));
107 GlobalUnlock( hmem );
109 TRACE("returning %p\n",hmem);
111 return hmem;
115 /***********************************************************************
116 * DllMain (OLE32.@)
118 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
120 TRACE("%p 0x%lx %p\n", hinstDLL, fdwReason, fImpLoad);
122 switch(fdwReason) {
123 case DLL_PROCESS_ATTACH:
124 OLE32_hInstance = hinstDLL;
125 COMPOBJ_InitProcess();
126 if (TRACE_ON(ole)) CoRegisterMallocSpy((LPVOID)-1);
127 break;
129 case DLL_PROCESS_DETACH:
130 if (TRACE_ON(ole)) CoRevokeMallocSpy();
131 COMPOBJ_UninitProcess();
132 OLE32_hInstance = 0;
133 break;
135 case DLL_THREAD_DETACH:
136 COM_TlsDestroy();
137 break;
139 return TRUE;
142 /* NOTE: DllRegisterServer and DllUnregisterServer are in regsvr.c */