Re: Serial ID from Win32
- Posted by Brian Broker <bkb at CNW.COM> Dec 04, 2000
- 441 views
On Mon, 4 Dec 2000 15:04:16 -0500, Ck Lester wrote: >Brian, > >Yes, Volume Serial Number. Since I have no idea how to wrap a DLL function, >I'll need an existing function from an existing library... > >If you can provide some code I can just plug into my app, please do! > >Thanks! >ck OK, here you go... plug and chug away: --------------------------------------- include win32lib.ew constant xGetVolumeInfo = linkFunc( kernel32, "GetVolumeInformationA", {C_POINTER, C_POINTER, C_UINT, C_POINTER, C_POINTER, C_POINTER, C_POINTER, C_UINT }, C_INT) function getVolSerial( sequence root_dir ) -- Input: A string that contains the root directory of the volume to be -- described. A trailing backslash is required. For example, you -- would specify \\MyServer\MyShare as "\\\\MyServer\\MyShare\\", -- or the C drive as "C:\\". -- Output: Volume Serial Number atom mset, rootPathName, volSerNum, ret_val mset = new_memset() rootPathName = acquire_mem( mset, root_dir ) volSerNum = acquire_mem( mset, DWord ) if not c_func( xGetVolumeInfo, { rootPathName, NULL, NULL, volSerNum, NULL, NULL, NULL, NULL } ) then warnErr( "xGetVolumeInfo failed in function getVolSerial" ) end if ret_val = peek4u( volSerNum ) release_mem( mset ) return ret_val end function -- the following two lines are a test and can be deleted -- printf( 1, "Volume Serial Number: %x", getVolSerial( "C:\\" ) ) -- this can be verified by typing "vol" at the C: prompt if wait_key() then end if --------------------------------------- -- Questions? Comments? -- just let me know... -- Brian