GetLogicalDriveStrings

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

This is a multi-part message in MIME format.

------=_NextPart_000_0026_01C0C738.E05162E0
	charset="iso-8859-1"

The code I have works, but, is there a better way to do this for =
"GetLogicalDriveStrings"?

--DWORD GetLogicalDriveStrings(

--    DWORD  nBufferLength, // size of buffer=20
--    LPTSTR  lpBuffer  // address of buffer for drive strings=20
--   );=20
  . . . . .
 kernel32 =3D open_dll("kernel32.dll")
 if kernel32 =3D 0 then
  result =3D message_box(sprintf( "%s", { "Required dll: kernel32 not =
found . . ." } ), "Get Drives", MB_ICONERROR+MB_TASKMODAL )
  abort(-1)
 end if
 GetDrives =3D define_c_func(kernel32, "GetLogicalDriveStringsA",{C_INT, =
C_POINTER}, C_INT)
  ptr =3D allocate_string( "                                             =
                                          " )
  length =3D c_func(GetDrives, { buffer, ptr } )
 if length then
  result =3D message_box(sprintf( "\"%s\"", { peek4s( {ptr, length} ) } =
), "Drives", MB_ICONINFORMATION+MB_TASKMODAL )
 else
  result =3D message_box(sprintf( "%s", { "Can't access drives . . ." } =
), "Get Drives", MB_ICONERROR+MB_TASKMODAL )
  abort(-1)
 end if=20


------=_NextPart_000_0026_01C0C738.E05162E0
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 bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>The code I have works, but, is there a =
better way=20
to do this for&nbsp;"GetLogicalDriveStrings"?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New" size=3D2>--DWORD=20
GetLogicalDriveStrings(</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New" size=3D2>--&nbsp;&nbsp;&nbsp; =
DWORD&nbsp;=20
nBufferLength,&nbsp;// size of buffer <BR>--&nbsp;&nbsp;&nbsp; =
LPTSTR&nbsp;=20
lpBuffer &nbsp;// address of buffer for drive strings <BR>--&nbsp;&nbsp; =

);&nbsp;<BR></FONT><FONT size=3D2><FONT face=3DArial>&nbsp; . . . .=20
.</FONT></DIV></FONT>
<DIV><FONT face=3D"Courier New" size=3D2>&nbsp;kernel32 =3D=20
open_dll("kernel32.dll")<BR>&nbsp;if kernel32 =3D 0 =
then<BR>&nbsp;&nbsp;result =3D=20
message_box(sprintf( "%s", { "Required dll: kernel32 not found . . ." } =
), "Get=20
Drives", MB_ICONERROR+MB_TASKMODAL =
)<BR>&nbsp;&nbsp;abort(-1)<BR>&nbsp;end=20
if<BR>&nbsp;GetDrives =3D define_c_func(kernel32,=20
"GetLogicalDriveStringsA",{C_INT, C_POINTER}, C_INT)<BR>&nbsp; ptr =3D=20
allocate_string(=20
"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;=20
" )<BR>&nbsp; length =3D c_func(GetDrives, { buffer, ptr } )<BR>&nbsp;if =
length=20
then<BR>&nbsp;&nbsp;result =3D message_box(sprintf( "\"%s\"", { peek4s( =
{ptr,=20
length} ) } ), "Drives", MB_ICONINFORMATION+MB_TASKMODAL=20
)<BR>&nbsp;else<BR>&nbsp;&nbsp;result =3D message_box(sprintf( "%s", { =
"Can't=20
access drives . . ." } ), "Get Drives", MB_ICONERROR+MB_TASKMODAL=20
)<BR>&nbsp;&nbsp;abort(-1)<BR>&nbsp;end if </FONT></DIV>

------=_NextPart_000_0026_01C0C738.E05162E0--

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

Search



Quick Links

User menu

Not signed in.

Misc Menu