ShellExecuteEx() problem

new topic     » topic index » view thread      » older message » newer message

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.&nbsp; Thanks in advance . . .</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</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>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New" size=3D1>global=20
constant<BR>&nbsp;cbSize&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=3D allot( DWord=20
),<BR>&nbsp;fMask&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=3D allot( Long=20
),<BR>&nbsp;hwnd&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=3D allot( Hndl=20
),<BR>&nbsp;lpVerb&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=3D allot( Ptr=20
),<BR>&nbsp;lpFile&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=3D allot( Ptr =
),<BR>&nbsp;lpParameters=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=3D allot( Ptr =
),<BR>&nbsp;lpDirectory&nbsp;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=3D allot( Ptr=20
),<BR>&nbsp;nShow&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=3D allot( Integer=20
),<BR>&nbsp;hInstApp&nbsp;&nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=3D allot( Hndl=20
),<BR>&nbsp;lpIDList&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
=3D allot( Ptr=20
),<BR>&nbsp;lpClass&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
=3D allot( Ptr=20
),<BR>&nbsp;hkeyClass&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
=3D allot( Hndl=20
),<BR>&nbsp;dwHotKey&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
=3D allot( DWord=20
),<BR>&nbsp;hIcon&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
=3D allot( Hndl ),<BR>&nbsp;hProcess&nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=3D allot( Hndl=20
),<BR>&nbsp;SIZEOF_SHELLEXECUTEINFO =3D =
allotted_size()&nbsp;</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D1></FONT>&nbsp;</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>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New" size=3D1>constant&nbsp; =
Win&nbsp;&nbsp;&nbsp;&nbsp;=20
=3D create ( Window,&nbsp;&nbsp;&nbsp;&nbsp; "Test ShellExecuteEx ",=20
0,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Default, Default, =
250, 100, 0=20
),<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;btTest&nbsp; =3D create ( =
PushButton,=20
"Check",&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;=20
Win,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;=20
10,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 10, 225,&nbsp; 50, 0 )</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D1></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New" size=3D1>procedure=20
onClick_btTest()<BR>&nbsp;sequence OScommand<BR>&nbsp;object=20
result&nbsp;<BR>&nbsp;atom shell32<BR>&nbsp;atom kernel32<BR>&nbsp;atom=20
user32<BR>&nbsp;atom rv<BR>&nbsp;atom memset1<BR>&nbsp;atom=20
memset2<BR>&nbsp;atom ptShell<BR>&nbsp;atom pVerb<BR>&nbsp;atom=20
pFile<BR>&nbsp;atom pParameters<BR>&nbsp;atom pDirectory<BR>&nbsp;atom=20
getLastError<BR>&nbsp;atom nError<BR>&nbsp;integer =
shellExecute</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D1></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New" =
size=3D1>&nbsp;memset1&nbsp;&nbsp;&nbsp;&nbsp; =3D=20
new_memset()<BR>&nbsp;ptShell&nbsp;&nbsp;&nbsp;&nbsp; =3D =
acquire_mem(memset1,=20
SIZEOF_SHELLEXECUTEINFO)</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D1></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New" size=3D1>&nbsp;store(ptShell, cbSize,=20
SIZEOF_SHELLEXECUTEINFO)<BR>&nbsp;store(ptShell, fMask,=20
SEE_MASK_NOCLOSEPROCESS)<BR>&nbsp;store(ptShell, hwnd, Win)</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D1></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New"=20
size=3D1>&nbsp;pVerb&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =3D =
allocate_string( "open"=20
)<BR>&nbsp;store(ptShell, lpVerb, pVerb)</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D1></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New"=20
size=3D1>&nbsp;pFile&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =3D =
allocate_string( "crc"=20
)<BR>&nbsp;store(ptShell, lpFile, pFile)</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D1></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New" size=3D1>--&nbsp;pParameters =3D=20
allocate_string(&nbsp; )<BR>--&nbsp;store(ptShell, lpParameters,=20
pParameters)</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D1></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New" size=3D1>--&nbsp;pDirectory&nbsp; =3D=20
allocate_string(&nbsp; )<BR>--&nbsp;store(ptShell, lpDirectory,=20
pDirectory)</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D1></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New" size=3D1>&nbsp;store(ptShell, nShow,=20
SW_SHOWNORMAL)</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D1></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New" size=3D1>&nbsp;shell32 =3D=20
open_dll("shell32.dll")<BR>&nbsp;if shell32 =3D 0 =
then<BR>&nbsp;&nbsp;result =3D=20
message_box(sprintf( "%s", { "Required dll: shell32 not found . . ." } =
),=20
"Test", MB_ICONERROR+MB_TASKMODAL =
)<BR>&nbsp;&nbsp;abort(-1)<BR>&nbsp;end=20
if<BR>&nbsp;kernel32 =3D open_dll("kernel32.dll")<BR>&nbsp;if kernel32 =
=3D 0=20
then<BR>&nbsp;&nbsp;result =3D message_box(sprintf( "%s", { "Required =
dll:=20
kernel32 not found . . ." } ), "Test", MB_ICONERROR+MB_TASKMODAL=20
)<BR>&nbsp;&nbsp;abort(-1)<BR>&nbsp;end if<BR>&nbsp;shellExecute =3D=20
define_c_func(shell32,&nbsp; "ShellExecuteEx", { C_POINTER }, C_INT=20
)<BR>&nbsp;getLastError =3D define_c_func(kernel32, =
"GetLastError",&nbsp;&nbsp;=20
{}, C_INT )<BR>&nbsp;rv =3D c_func(shellExecute, { ptShell } =
)<BR>&nbsp;result =3D=20
message_box (sprintf( "shellExecute rv: %d", rv ), "Test", 0 =
)<BR>&nbsp;rv =3D=20
c_func(getLastError, {} )<BR>&nbsp;result =3D message_box (sprintf( =
"getLastError=20
rv: %d", rv ), "Test", 0 )</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D1></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New" size=3D1>end procedure</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D1></FONT>&nbsp;</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>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New" size=3D1>WinMain( Win, Normal=20

------=_NextPart_000_000E_01C0E86C.82520820--

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu