+ add and initialize the win16 system unit variables that correspond to the

WinMain parameters in C

git-svn-id: trunk@31547 -
This commit is contained in:
nickysn 2015-09-06 10:25:34 +00:00
parent 83a7fa2320
commit eea09632a3
4 changed files with 29 additions and 6 deletions

View File

@ -53,7 +53,9 @@ function Is_IntResource(aStr : pchar) : boolean; {$ifdef SYSTEMINLINE}inline;{$e
function MakeLangID(primary,sub : word) : word; {$ifdef SYSTEMINLINE}inline;{$endif}
// Win32 API compatible Resource functions
{$ifndef Win16}
Function HINSTANCE : TFPResourceHMODULE;
{$endif Win16}
Function EnumResourceTypes(ModuleHandle : TFPResourceHMODULE; EnumFunc : EnumResTypeProc; lParam : PtrInt) : LongBool;
Function EnumResourceNames(ModuleHandle : TFPResourceHMODULE; ResourceType : PChar; EnumFunc : EnumResNameProc; lParam : PtrInt) : LongBool;
Function EnumResourceLanguages(ModuleHandle : TFPResourceHMODULE; ResourceType, ResourceName : PChar; EnumFunc : EnumResLangProc; lParam : PtrInt) : LongBool;

View File

@ -141,10 +141,12 @@ end;
*****************************************************************************)
{ These functions will call the specified resource manager functions }
{$ifndef Win16}
Function HINSTANCE : TFPResourceHMODULE;
begin
Result:=resourcemanager.HINSTANCEFunc();
end;
{$endif Win16}
Function EnumResourceTypes(ModuleHandle : TFPResourceHMODULE; EnumFunc : EnumResTypeProc; lParam : PtrInt) : LongBool;
begin

View File

@ -27,6 +27,10 @@
extern PASCALMAIN
extern __fpc_PrefixSeg
extern __fpc_CmdLine
extern __fpc_CmdShow
extern __fpc_HInstance
extern __fpc_HPrevInst
extern InitTask
import InitTask KERNEL
@ -67,7 +71,11 @@
mov ax, es
mov [__fpc_PrefixSeg], ax
mov [hInst], di
mov [__fpc_CmdLine+2], ax
mov [__fpc_CmdLine], bx
mov [__fpc_CmdShow], dx
mov [__fpc_HInstance], di
mov [__fpc_HPrevInst], si
; call WaitEvent(0) to clear the event that started this task
; Windows expects this call immediately after InitTask
@ -75,10 +83,10 @@
push ax
call far WaitEvent
; call InitApp(hInst) to initialize the queue and support routines
; for the app. Windows expects this to be the third call in the
; Win16 startup sequence.
push word [hInst]
; call InitApp(hInstance) to initialize the queue and support
; routines for the app. Windows expects this to be the third
; call in the Win16 startup sequence.
push word [__fpc_HInstance]
call far InitApp
test ax, ax
jz error
@ -108,7 +116,6 @@ pStackBot: dw 0
; end of reserved area, filled by InitTask
hInst: dw 0
segment _STACK stack class=STACK align=16

View File

@ -13,6 +13,8 @@ interface
systemh.inc is included otherwise the
$mode switch is not effective }
{$DEFINE HAS_CMDLINE}
{$I systemh.inc}
{$I tnyheaph.inc}
@ -52,6 +54,9 @@ const
64K bytes (BP7 compatibility) }
SelectorInc: Word = $1000;
type
LPSTR = ^Char;far;
var
{ Mem[] support }
mem : array[0..$7fff-1] of byte absolute $0:$0;
@ -66,6 +71,13 @@ var
{ The DOS Program Segment Prefix segment (TP7 compatibility) }
PrefixSeg:Word;public name '__fpc_PrefixSeg';
{ BP7 compatible windows variables }
{ In C, these are the parameters to WinMain }
CmdLine: LPSTR;public name '__fpc_CmdLine';
CmdShow: SmallInt;public name '__fpc_CmdShow';
HInstance: Word{HINST};public name '__fpc_HInstance';
HPrevInst: Word{HINST};public name '__fpc_HPrevInst';
{ SaveInt00: FarPointer;public name '__SaveInt00';}
AllFilesMask: string [3];