Streamline dlls/ and programs/ in terms of indentation.
[wine/dcerpc.git] / dlls / ole32 / ole32_main.c
blob95afa864297279b932bf4e7a3ea9956d00ad3440
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>
23 #include "windef.h"
24 #include "winerror.h"
25 #include "winbase.h"
26 #include "wingdi.h"
27 #include "winuser.h"
28 #include "ole32_main.h"
29 #include "wine/debug.h"
31 WINE_DEFAULT_DEBUG_CHANNEL(ole);
33 HINSTANCE OLE32_hInstance = 0;
35 /***********************************************************************
36 * OleMetafilePictFromIconAndLabel (OLE32.@)
38 HGLOBAL WINAPI OleMetafilePictFromIconAndLabel(HICON hIcon, LPOLESTR lpszLabel,
39 LPOLESTR lpszSourceFile, UINT iIconIndex)
41 HMETAFILE hmf;
42 HDC hdc;
43 UINT dy, mfsize;
44 HGLOBAL hmem = 0;
45 LPVOID mfdata;
47 TRACE("%p %p %p %d\n", hIcon, lpszLabel, lpszSourceFile, iIconIndex);
49 if( !hIcon )
50 return 0;
52 hdc = CreateMetaFileW(NULL);
53 if( !hdc )
54 return 0;
56 /* FIXME: things are drawn in the wrong place */
57 DrawIcon(hdc, 0, 0, hIcon);
58 dy = GetSystemMetrics(SM_CXICON);
59 if(lpszLabel)
60 TextOutW(hdc, 0, dy, lpszLabel, lstrlenW(lpszLabel));
62 hmf = CloseMetaFile(hdc);
63 if( !hmf )
64 return 0;
66 mfsize = GetMetaFileBitsEx( hmf, 0, NULL);
67 if( !mfsize )
68 goto end;
70 hmem = GlobalAlloc( GMEM_MOVEABLE, mfsize );
71 if( !hmem )
72 goto end;
74 mfdata = GlobalLock( hmem );
75 if( !mfdata )
77 GlobalFree( hmem );
78 hmem = 0;
79 goto end;
82 GetMetaFileBitsEx( hmf, mfsize, mfdata );
83 GlobalUnlock( hmem );
84 end:
85 DeleteMetaFile(hmf);
87 TRACE("returning %p\n",hmem);
89 return hmem;
93 /***********************************************************************
94 * DllMain (OLE32.@)
96 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
98 TRACE("%p 0x%lx %p\n", hinstDLL, fdwReason, fImpLoad);
100 switch(fdwReason) {
101 case DLL_PROCESS_ATTACH:
102 DisableThreadLibraryCalls(hinstDLL);
103 OLE32_hInstance = hinstDLL;
104 COMPOBJ_InitProcess();
105 if (TRACE_ON(ole)) CoRegisterMallocSpy((LPVOID)-1);
106 break;
108 case DLL_PROCESS_DETACH:
109 if (TRACE_ON(ole)) CoRevokeMallocSpy();
110 COMPOBJ_UninitProcess();
111 OLE32_hInstance = 0;
112 break;
114 return TRUE;
117 /* NOTE: DllRegisterServer and DllUnregisterServer are in regsvr.c */