PDB symbol header format depends only on version code.
[wine/dcerpc.git] / windows / winhelp.c
blobf66422178dca9e3532591ffafac07c46cc880519
1 /*
2 * Windows Help
3 */
5 #include <stdlib.h>
6 #include <stdio.h>
7 #include <string.h>
8 #include <unistd.h>
9 #include "debugtools.h"
10 #include "windef.h"
11 #include "wingdi.h"
12 #include "wine/winuser16.h"
13 #include "wine/winbase16.h"
14 #include "heap.h"
15 #include "ldt.h"
16 #include "syslevel.h"
18 DEFAULT_DEBUG_CHANNEL(win);
21 /* WinHelp internal structure */
22 typedef struct
24 WORD size;
25 WORD command;
26 LONG data;
27 LONG reserved;
28 WORD ofsFilename;
29 WORD ofsData;
30 } WINHELP,*LPWINHELP;
32 /**********************************************************************
33 * WinHelp16 (USER.171)
35 BOOL16 WINAPI WinHelp16( HWND16 hWnd, LPCSTR lpHelpFile, UINT16 wCommand,
36 DWORD dwData )
38 BOOL ret;
39 /* We might call WinExec() */
40 SYSLEVEL_ReleaseWin16Lock();
42 if (!(ret = WinHelpA( hWnd, lpHelpFile, wCommand, (DWORD)PTR_SEG_TO_LIN(dwData) )))
44 /* try to start the 16-bit winhelp */
45 if (WinExec( "winhelp.exe -x", SW_SHOWNORMAL ) >= 32)
47 Yield16();
48 ret = WinHelpA( hWnd, lpHelpFile, wCommand, (DWORD)PTR_SEG_TO_LIN(dwData) );
52 SYSLEVEL_RestoreWin16Lock();
53 return ret;
57 /**********************************************************************
58 * WinHelpA (USER32.579)
60 BOOL WINAPI WinHelpA( HWND hWnd, LPCSTR lpHelpFile, UINT wCommand,
61 DWORD dwData )
63 static WORD WM_WINHELP = 0;
64 HWND hDest;
65 LPWINHELP lpwh;
66 HGLOBAL16 hwh;
67 int size,dsize,nlen;
70 if(!WM_WINHELP)
72 WM_WINHELP=RegisterWindowMessageA("WM_WINHELP");
73 if(!WM_WINHELP)
74 return FALSE;
77 hDest = FindWindowA( "MS_WINHELP", NULL );
78 if(!hDest) {
79 if(wCommand == HELP_QUIT) return TRUE;
80 if (WinExec ( "winhlp32.exe -x", SW_SHOWNORMAL ) < 32) return FALSE;
81 if ( ! ( hDest = FindWindowA ( "MS_WINHELP", NULL ) )) return FALSE;
85 switch(wCommand)
87 case HELP_CONTEXT:
88 case HELP_SETCONTENTS:
89 case HELP_CONTENTS:
90 case HELP_CONTEXTPOPUP:
91 case HELP_FORCEFILE:
92 case HELP_HELPONHELP:
93 case HELP_FINDER:
94 case HELP_QUIT:
95 dsize=0;
96 break;
97 case HELP_KEY:
98 case HELP_PARTIALKEY:
99 case HELP_COMMAND:
100 dsize = dwData ? strlen( (LPSTR)dwData )+1: 0;
101 break;
102 case HELP_MULTIKEY:
103 dsize = ((LPMULTIKEYHELPA)dwData)->mkSize;
104 break;
105 case HELP_SETWINPOS:
106 dsize = ((LPHELPWININFOA)dwData)->wStructSize;
107 break;
108 default:
109 WARN("Unknown help command %d\n",wCommand);
110 return FALSE;
112 if(lpHelpFile)
113 nlen = strlen(lpHelpFile)+1;
114 else
115 nlen = 0;
116 size = sizeof(WINHELP) + nlen + dsize;
117 hwh = GlobalAlloc16(0,size);
118 lpwh = GlobalLock16(hwh);
119 lpwh->size = size;
120 lpwh->command = wCommand;
121 lpwh->data = dwData;
122 if(nlen) {
123 strcpy(((char*)lpwh) + sizeof(WINHELP),lpHelpFile);
124 lpwh->ofsFilename = sizeof(WINHELP);
125 } else
126 lpwh->ofsFilename = 0;
127 if(dsize) {
128 memcpy(((char*)lpwh)+sizeof(WINHELP)+nlen,(LPSTR)dwData,dsize);
129 lpwh->ofsData = sizeof(WINHELP)+nlen;
130 } else
131 lpwh->ofsData = 0;
132 GlobalUnlock16(hwh);
133 return SendMessage16(hDest,WM_WINHELP,hWnd,hwh);
137 /**********************************************************************
138 * WinHelpW (USER32.580)
140 BOOL WINAPI WinHelpW( HWND hWnd, LPCWSTR helpFile, UINT command,
141 DWORD dwData )
143 LPSTR file = HEAP_strdupWtoA( GetProcessHeap(), 0, helpFile );
144 BOOL ret = WinHelpA( hWnd, file, command, dwData );
145 HeapFree( GetProcessHeap(), 0, file );
146 return ret;