Corrected a potential crash.
[wine] / libtest / hello5.c
1 /*
2  * This example demonstrates dynamical loading of (internal) Win32 DLLS.
3  */
4 #include <stdio.h>
5 #include <windows.h>
6
7 int PASCAL WinMain (HANDLE inst, HANDLE prev, LPSTR cmdline, int show)
8 {
9         SYSTEM_INFO     si;
10         void (CALLBACK *fnGetSystemInfo)(LPSYSTEM_INFO si);
11         HMODULE kernel32;
12
13         kernel32 = LoadLibrary("KERNEL32");
14         if (kernel32<32) {
15                 fprintf(stderr,"FATAL: could not load KERNEL32!\n");
16                 return 0;
17         }
18         fnGetSystemInfo = (void*)GetProcAddress(kernel32,"GetSystemInfo");
19         if (!fnGetSystemInfo) {
20                 fprintf(stderr,"FATAL: could not find GetSystemInfo!\n");
21                 return 0;
22         }
23         fnGetSystemInfo(&si);
24         fprintf(stderr,"QuerySystemInfo returns:\n");
25         fprintf(stderr,"        wProcessorArchitecture: %d\n",si.u.s.wProcessorArchitecture);
26         fprintf(stderr,"        dwPageSize: %ld\n",si.dwPageSize);
27         fprintf(stderr,"        lpMinimumApplicationAddress: %p\n",si.lpMinimumApplicationAddress);
28         fprintf(stderr,"        lpMaximumApplicationAddress: %p\n",si.lpMaximumApplicationAddress);
29         fprintf(stderr,"        dwActiveProcessorMask: %ld\n",si.dwActiveProcessorMask);
30         fprintf(stderr,"        dwNumberOfProcessors: %ld\n",si.dwNumberOfProcessors);
31         fprintf(stderr,"        dwProcessorType: %ld\n",si.dwProcessorType);
32         fprintf(stderr,"        dwAllocationGranularity: %ld\n",si.dwAllocationGranularity);
33         fprintf(stderr,"        wProcessorLevel: %d\n",si.wProcessorLevel);
34         fprintf(stderr,"        wProcessorRevision: %d\n",si.wProcessorRevision);
35         return 0;
36 }