ShellExecuteEx() problem
- Posted by jjnick at cvn.com May 29, 2001
- 455 views
This is a multi-part message in MIME format. ------=_NextPart_000_000E_01C0E86C.82520820 charset="iso-8859-1" I am obviously not setting the structure up correctly or something = stupid, so, could somebody please point out my mistake. Thanks in = advance . . . include win32lib.ew without warning global constant cbSize =3D allot( DWord ), fMask =3D allot( Long ), hwnd =3D allot( Hndl ), lpVerb =3D allot( Ptr ), lpFile =3D allot( Ptr ), lpParameters =3D allot( Ptr ), lpDirectory =3D allot( Ptr ), nShow =3D allot( Integer ), hInstApp =3D allot( Hndl ), lpIDList =3D allot( Ptr ), lpClass =3D allot( Ptr ), hkeyClass =3D allot( Hndl ), dwHotKey =3D allot( DWord ), hIcon =3D allot( Hndl ), hProcess =3D allot( Hndl ), SIZEOF_SHELLEXECUTEINFO =3D allotted_size()=20 constant SEE_MASK_NOCLOSEPROCESS =3D #40 constant Win =3D create ( Window, "Test ShellExecuteEx ", 0, = Default, Default, 250, 100, 0 ), btTest =3D create ( PushButton, "Check", Win, = 10, 10, 225, 50, 0 ) procedure onClick_btTest() sequence OScommand object result=20 atom shell32 atom kernel32 atom user32 atom rv atom memset1 atom memset2 atom ptShell atom pVerb atom pFile atom pParameters atom pDirectory atom getLastError atom nError integer shellExecute memset1 =3D new_memset() ptShell =3D acquire_mem(memset1, SIZEOF_SHELLEXECUTEINFO) store(ptShell, cbSize, SIZEOF_SHELLEXECUTEINFO) store(ptShell, fMask, SEE_MASK_NOCLOSEPROCESS) store(ptShell, hwnd, Win) pVerb =3D allocate_string( "open" ) store(ptShell, lpVerb, pVerb) pFile =3D allocate_string( "crc" ) store(ptShell, lpFile, pFile) -- pParameters =3D allocate_string( ) -- store(ptShell, lpParameters, pParameters) -- pDirectory =3D allocate_string( ) -- store(ptShell, lpDirectory, pDirectory) store(ptShell, nShow, SW_SHOWNORMAL) shell32 =3D open_dll("shell32.dll") if shell32 =3D 0 then result =3D message_box(sprintf( "%s", { "Required dll: shell32 not = found . . ." } ), "Test", MB_ICONERROR+MB_TASKMODAL ) abort(-1) end if kernel32 =3D open_dll("kernel32.dll") if kernel32 =3D 0 then result =3D message_box(sprintf( "%s", { "Required dll: kernel32 not = found . . ." } ), "Test", MB_ICONERROR+MB_TASKMODAL ) abort(-1) end if shellExecute =3D define_c_func(shell32, "ShellExecuteEx", { C_POINTER = }, C_INT ) getLastError =3D define_c_func(kernel32, "GetLastError", {}, C_INT ) rv =3D c_func(shellExecute, { ptShell } ) result =3D message_box (sprintf( "shellExecute rv: %d", rv ), "Test", 0 = ) rv =3D c_func(getLastError, {} ) result =3D message_box (sprintf( "getLastError rv: %d", rv ), "Test", 0 = ) end procedure onClick [ btTest ] =3D routine_id( "onClick_btTest" ) WinMain( Win, Normal ) ------=_NextPart_000_000E_01C0E86C.82520820 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META http-equiv=3DContent-Type content=3D"text/html; = charset=3Diso-8859-1"> <META content=3D"MSHTML 5.50.4134.600" name=3DGENERATOR> <STYLE></STYLE> </HEAD> <BODY> <DIV><FONT face=3DArial size=3D2>I am obviously not setting the = structure up=20 correctly or something stupid, so, could somebody please point out my=20 mistake. Thanks in advance . . .</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2></FONT><FONT face=3D"Courier New" = size=3D1>include=20 win32lib.ew<BR>without warning</FONT></DIV> <DIV><FONT face=3D"Courier New" size=3D1></FONT> </DIV> <DIV><FONT face=3D"Courier New" size=3D1>global=20 constant<BR> cbSize =20 =3D allot( DWord=20 ),<BR> fMask =20 =3D allot( Long=20 ),<BR> hwnd =20 =3D allot( Hndl=20 ),<BR> lpVerb =20 =3D allot( Ptr=20 ),<BR> lpFile =20 =3D allot( Ptr = ),<BR> lpParameters=20 =3D allot( Ptr = ),<BR> lpDirectory =20 =3D allot( Ptr=20 ),<BR> nShow =20 =3D allot( Integer=20 ),<BR> hInstApp =20 =3D allot( Hndl=20 ),<BR> lpIDList  = ; =20 =3D allot( Ptr=20 ),<BR> lpClass = =20 =3D allot( Ptr=20 ),<BR> hkeyClass &nbs= p; =20 =3D allot( Hndl=20 ),<BR> dwHotKey  = ; =20 =3D allot( DWord=20 ),<BR> hIcon &n= bsp; =20 =3D allot( Hndl ),<BR> hProcess =20 =3D allot( Hndl=20 ),<BR> SIZEOF_SHELLEXECUTEINFO =3D = allotted_size() </FONT></DIV> <DIV><FONT face=3D"Courier New" size=3D1></FONT> </DIV> <DIV><FONT face=3D"Courier New" size=3D1>constant = SEE_MASK_NOCLOSEPROCESS =3D=20 #40</FONT></DIV> <DIV><FONT face=3D"Courier New" size=3D1></FONT> </DIV> <DIV><FONT face=3D"Courier New" size=3D1>constant = Win =20 =3D create ( Window, "Test ShellExecuteEx ",=20 0, Default, Default, = 250, 100, 0=20 ),<BR> btTest =3D create ( = PushButton,=20 "Check",  = ; =20 Win, &nb= sp; =20 10, 10, 225, 50, 0 )</FONT></DIV> <DIV><FONT face=3D"Courier New" size=3D1></FONT> </DIV> <DIV><FONT face=3D"Courier New" size=3D1>procedure=20 onClick_btTest()<BR> sequence OScommand<BR> object=20 result <BR> atom shell32<BR> atom kernel32<BR> atom=20 user32<BR> atom rv<BR> atom memset1<BR> atom=20 memset2<BR> atom ptShell<BR> atom pVerb<BR> atom=20 pFile<BR> atom pParameters<BR> atom pDirectory<BR> atom=20 getLastError<BR> atom nError<BR> integer = shellExecute</FONT></DIV> <DIV><FONT face=3D"Courier New" size=3D1></FONT> </DIV> <DIV><FONT face=3D"Courier New" = size=3D1> memset1 =3D=20 new_memset()<BR> ptShell =3D = acquire_mem(memset1,=20 SIZEOF_SHELLEXECUTEINFO)</FONT></DIV> <DIV><FONT face=3D"Courier New" size=3D1></FONT> </DIV> <DIV><FONT face=3D"Courier New" size=3D1> store(ptShell, cbSize,=20 SIZEOF_SHELLEXECUTEINFO)<BR> store(ptShell, fMask,=20 SEE_MASK_NOCLOSEPROCESS)<BR> store(ptShell, hwnd, Win)</FONT></DIV> <DIV><FONT face=3D"Courier New" size=3D1></FONT> </DIV> <DIV><FONT face=3D"Courier New"=20 size=3D1> pVerb =3D = allocate_string( "open"=20 )<BR> store(ptShell, lpVerb, pVerb)</FONT></DIV> <DIV><FONT face=3D"Courier New" size=3D1></FONT> </DIV> <DIV><FONT face=3D"Courier New"=20 size=3D1> pFile =3D = allocate_string( "crc"=20 )<BR> store(ptShell, lpFile, pFile)</FONT></DIV> <DIV><FONT face=3D"Courier New" size=3D1></FONT> </DIV> <DIV><FONT face=3D"Courier New" size=3D1>-- pParameters =3D=20 allocate_string( )<BR>-- store(ptShell, lpParameters,=20 pParameters)</FONT></DIV> <DIV><FONT face=3D"Courier New" size=3D1></FONT> </DIV> <DIV><FONT face=3D"Courier New" size=3D1>-- pDirectory =3D=20 allocate_string( )<BR>-- store(ptShell, lpDirectory,=20 pDirectory)</FONT></DIV> <DIV><FONT face=3D"Courier New" size=3D1></FONT> </DIV> <DIV><FONT face=3D"Courier New" size=3D1> store(ptShell, nShow,=20 SW_SHOWNORMAL)</FONT></DIV> <DIV><FONT face=3D"Courier New" size=3D1></FONT> </DIV> <DIV><FONT face=3D"Courier New" size=3D1> shell32 =3D=20 open_dll("shell32.dll")<BR> if shell32 =3D 0 = then<BR> result =3D=20 message_box(sprintf( "%s", { "Required dll: shell32 not found . . ." } = ),=20 "Test", MB_ICONERROR+MB_TASKMODAL = )<BR> abort(-1)<BR> end=20 if<BR> kernel32 =3D open_dll("kernel32.dll")<BR> if kernel32 = =3D 0=20 then<BR> result =3D message_box(sprintf( "%s", { "Required = dll:=20 kernel32 not found . . ." } ), "Test", MB_ICONERROR+MB_TASKMODAL=20 )<BR> abort(-1)<BR> end if<BR> shellExecute =3D=20 define_c_func(shell32, "ShellExecuteEx", { C_POINTER }, C_INT=20 )<BR> getLastError =3D define_c_func(kernel32, = "GetLastError", =20 {}, C_INT )<BR> rv =3D c_func(shellExecute, { ptShell } = )<BR> result =3D=20 message_box (sprintf( "shellExecute rv: %d", rv ), "Test", 0 = )<BR> rv =3D=20 c_func(getLastError, {} )<BR> result =3D message_box (sprintf( = "getLastError=20 rv: %d", rv ), "Test", 0 )</FONT></DIV> <DIV><FONT face=3D"Courier New" size=3D1></FONT> </DIV> <DIV><FONT face=3D"Courier New" size=3D1>end procedure</FONT></DIV> <DIV><FONT face=3D"Courier New" size=3D1></FONT> </DIV> <DIV><FONT face=3D"Courier New" size=3D1>onClick [ btTest ] =3D = routine_id(=20 "onClick_btTest" )</FONT></DIV> <DIV><FONT face=3D"Courier New" size=3D1></FONT> </DIV> <DIV><FONT face=3D"Courier New" size=3D1>WinMain( Win, Normal=20 ------=_NextPart_000_000E_01C0E86C.82520820--