1. GetLogicalDriveStrings
- Posted by jjnick at cvn.com Apr 17, 2001
- 419 views
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 "GetLogicalDriveStrings"?</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3D"Courier New" size=3D2>--DWORD=20 GetLogicalDriveStrings(</FONT></DIV> <DIV><FONT face=3D"Courier New" size=3D2></FONT> </DIV> <DIV><FONT face=3D"Courier New" size=3D2>-- = DWORD =20 nBufferLength, // size of buffer <BR>-- = LPTSTR =20 lpBuffer // address of buffer for drive strings <BR>-- = ); <BR></FONT><FONT size=3D2><FONT face=3DArial> . . . .=20 .</FONT></DIV></FONT> <DIV><FONT face=3D"Courier New" size=3D2> kernel32 =3D=20 open_dll("kernel32.dll")<BR> if kernel32 =3D 0 = then<BR> result =3D=20 message_box(sprintf( "%s", { "Required dll: kernel32 not found . . ." } = ), "Get=20 Drives", MB_ICONERROR+MB_TASKMODAL = )<BR> abort(-1)<BR> end=20 if<BR> GetDrives =3D define_c_func(kernel32,=20 "GetLogicalDriveStringsA",{C_INT, C_POINTER}, C_INT)<BR> ptr =3D=20 allocate_string(=20 " = &= nbsp; &n= bsp; &nb= sp; &nbs= p;  = ; = =20 " )<BR> length =3D c_func(GetDrives, { buffer, ptr } )<BR> if = length=20 then<BR> result =3D message_box(sprintf( "\"%s\"", { peek4s( = {ptr,=20 length} ) } ), "Drives", MB_ICONINFORMATION+MB_TASKMODAL=20 )<BR> else<BR> result =3D message_box(sprintf( "%s", { = "Can't=20 access drives . . ." } ), "Get Drives", MB_ICONERROR+MB_TASKMODAL=20 )<BR> abort(-1)<BR> end if </FONT></DIV> ------=_NextPart_000_0026_01C0C738.E05162E0--