9:52 PM 30-OCT-01 STARTWEB routine STARTWEB STARTWEB(WEBSITE) ;Ophalen van de .exe file die Internet Explorer is [ 10/30/2001 9:49 PM ] ; ; This routine will startup your default web browser and open the website that is ; specified in the parameter WEBSITE. ; Example Make a form with a button. In the 'Push' event of the button put: ; D ^STARTWEB("www.georgejames.com") ; ; It works by first saving a dummy file with the extension .htm (WRITEFIL) ; Than we use an api-call to ask windows what application is connected to this file (FindEx) ; ; This routine was compiled by Henk Westerhof, westerhof@simar.nl ; with (very important) help from John Murray who provided the coding for the FindEx part. ; This code may be freely used by other MSM-WS users. ; Amsterdam, october 2001. ; N FILE,WEBAPP,DUM D WRITEFIL S WEBAPP=$$FindEx(FILE) ; ; Starting up the .exe file with the website as a parameter. ; This has been tested to work with Internet Explorer. S DUM=$$WINAPP^%HOSTCMD(WEBAPP_" "_WEBSITE) ; ;The disadvantage of this approach is that every time you run this routine ;with a different website, this will launch another instance of internet explorer. ;This could most likely be avoided by using OLE-automation to start Internet Explorer, ;followed by open commands; but that probably wouldn't work with different web browsers. ; Q ; -------------------- ; WRITEFIL ; Write a dummy file with extension .htm ; N PATH,SUCCES ; First find out in what drive/dir we are S PATH=$$APPEXE^%msc S PATH=$P(PATH,"\",1,$L(PATH,"\")-1)_"\" ; ;In this directory we write a dummy file with the extension .htm S FILE=PATH_"\DUMMY.HTM" S SUCCES=$$OPEN^%msc(FILE,"W",.FDEV) I SUCCES D I^%msgbox("Writing a file failed. Error="_SUCCES,"ERROR") Q ; ; FDEV is nu 51 ; U FDEV W "DUMMY FILE",! ; C FDEV ; Q ; ----- ; FindEx(FullFnam) ; ;Get the application, connected to a filename ;Coding based upon Microsoft idea and M-coding by John Murray N file,path S path=$P(FullFnam,"\",1,$L(FullFnam,"\")-1) S file=$P(FullFnam,"\",$L(FullFnam,"\")) N rslt,handle N lpFile,lpPath S lpFile=$ZMSM(1,$L(file)+1) V lpFile::file_$C(0):$L(file)+1:1 S lpPath=$ZMSM(1,$L(path)+1) V lpPath::path_$C(0):$L(path)+1:1 ; Get memory to receive the result N lpBuffer S lpBuffer=$ZMSM(1,256) ; Load the DLL that contains the API call we want S handle=$&MSM.LOADLIB("shell32.dll") ; Call the ANSI version of FindExecutable, because that should work on Win9x as well as NT S rslt=$&MSM.CALLENTRY(handle,"FindExecutableA",$$spar(lpFile)_$$spar(lpPath)_$$spar(lpBuffer)) ; Unload the DLL D &MSM.FREELIB(handle) ; If the call succeeded, fetch the result from the buffer I rslt>31 S rslt=$P($V(lpBuffer,-3,256,1),$C(0)) E S rslt="" ; Release the memory areas I $ZMSM(2,lpFile,$L(file)+1) I $ZMSM(2,lpPath,$L(path)+1) I $ZMSM(2,lpBuffer,256) ; return the result Q rslt ; spar(p) ; Encode a 32-bit value (typically a pointer to a memory buffer) ; ready for use in the third argument of &MSM.CALLENTRY N out,i S out="" I p<0 S p=4294967296+p F i=1:1:4 S out=$C(p#256)_out,p=p\256 Q out