Date: 02-16-2022
Return to Index
created by gbSnippets
'A Windows program begins with a WinMain function. The program ends when the
'WinMain function ends. A description of the content of the WinMain function is
'provided in the next several snippets.
'WinMain Function:
'Here's a simple look at the syntax of a WinMain function. The arguments,
'discussed further down this page, are provided by Windows to the application.
'They are NOT defined by the programmer.
Function WinMain (ByVal hInst, As DWord, ByVal hPrevInst As DWord, ByVal lpCmdLine As Asciiz PTR, ByVal iCmdShow As Long) As Long
End Function
'or, written in a multiline format:
Function WinMain (ByVal hInstance AS DWord, _
ByVal hPrevInstance AS DWord, _
ByVal lpCmdLine As AsciiZ PTR, _
ByVal iCmdShow As Long) As Long
End Function
'Here's a description of the four arguments:
hInstance 'current instance of the application
hPrevInstance 'previous instance (not used - returns %Null in Win32)
lpCmdLine 'pointer to command line (whatever the user types in after MyApp.EXE). A null terminated string.
iCmdShow 'used the first time ShowWindow is called to display the application main window
'Alternate Function Statements:
'For those of you who like shorter, one-liner versions these Function statements will compile just fine:
Function WinMain (ByVal hInst???, ByVal hPrevInstance???, ByVal lpCmdLine As Asciiz PTR, ByVal iCmdShow&) As Long
Function WinMain (ByVal A As DWord, ByVal B As DWord, ByVal C As Asciiz PTR, ByVal D As Long) As Long
'gbs_00305
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm