Opening a web browser from a B3D app?

Blitz3D Forums/Blitz3D Programming/Opening a web browser from a B3D app?

this uses WinExec to open Iexplore from the current windows drive. It needs 2 kernel32.dll decls given below.

The api says you should use CreateProcess but it's only a preference, this works just as well and is simpler.

No idea how to find the default browser though.

;WinExec example

;.lib "Kernel32.dll"
;Api_WinExec% (lpCmdLine$, nCmdShow%) : "WinExec"
;Api_GetWindowsDirectory% (lpBuffer*, nSize%) : "GetWindowsDirectoryA"

;winuser.h constants
Const SW_HIDE=0
Const SW_MAXIMIZE=3
Const SW_MINIMIZE=6
Const SW_RESTORE=9
Const SW_SHOW=5
Const SW_SHOWDEFAULT=10
Const SW_SHOWMAXIMIZED=3
Const SW_SHOWMINIMIZED=2
Const SW_SHOWMINNOACTIVE=7
Const SW_SHOWNA=8
Const SW_SHOWNOACTIVATE=4
Const SW_SHOWNORMAL=1

Graphics 640,480,0,2
SetBuffer BackBuffer()

bank=CreateBank(16)
charlen=Api_GetWindowsDirectory(bank,11) ;"C:\WINDOWS"
cmdline$=Chr(34)
For i=0 To 2 ;get drive letter from bank
 cmdline$=cmdline$+Chr(PeekByte(bank,i))
Next
cmdline$=cmdline$+"Program Files\Internet Explorer\IEXPLORE.EXE"+Chr(34)
cmdline$=cmdline$+" www.blitzbasic.com"

;result=Api_WinExec(cmdline$,SW_SHOW)

While Not KeyDown(1)
 Cls

 If KeyHit(57) ;space
  result=Api_WinExec(cmdline$,SW_SHOW)
 EndIf

 Text 0,0,"Press Space, result="+result
 Text 0,20,"cmdline$="+cmdline$

 Flip
Wend

;result
;"function succeeds">31
;"out of memory"=0
;ERROR_FILE_NOT_FOUND=2
;ERROR_PATH_NOT_FOUND=3
;ERROR_BAD_FORMAT=11