Domain Builder

  • Subscribe to our RSS feed.
  • Twitter
  • StumbleUpon
  • Reddit
  • Facebook
  • Digg

Wednesday, 23 January 2008

Get Volume Information

Posted on 20:40 by Unknown
In order to show a list of Drives We needed to get the name of the Drive. The following API call gets the volume name as well as the serial number.

Create an NVO add the following local external function:
function long GetVolumeInformationA( ref string ls_RootPath, &
ref string ls_VolName, long ll_VolLen, ref string ls_volserial, &
long ll_maxcomplen, long ll_systemflags, &
ref string ls_SystemName,&
long ll_SystemLen ) Library 'kernel32'

Then add a function called GetVolumeName which accepts a string and returns a string and add the following code:
// Call the API function to get the volume label from a drive letter
Long ll_Max, ll_Flags, ll_Ret, ll_FileSys
Long ll_Vol

String ls_Vol
String ls_Drv, ls_FileSys, ls_Flags, ls_Serial


ls_Drv = as_Vol
ls_Vol = Space(32)
ls_FileSys = Space(32)
ls_Serial = Space(32)
ll_Vol = Len( ls_Vol )
ll_FileSys = Len( ls_Filesys )

ll_Ret = GetVolumeInformationA( ls_Drv, ls_Vol, ll_Vol, &
ls_Serial, ll_Max, ll_Flags, ls_FileSys, ll_FileSys )

IF (ll_Ret = 0) THEN
ls_Vol = ''
ELSE
ls_Vol = Trim( ls_Vol )
END IF

RETURN (ls_Vol)

Call the function passing the drive you want the volume name for. For example C:\
Email ThisBlogThis!Share to XShare to Facebook
Posted in Win32 API | No comments
Newer Post Older Post Home

0 comments:

Post a Comment

Subscribe to: Post Comments (Atom)

Popular Posts

  • Using Windows Scripting Host
    You can use Windows Scripting Host on PowerBuilder for many purpose. On sample code below, you can use it to get the network domain, user na...
  • List available ODBC datasources
    You can list available ODBC datasources from within PowerBuilder. You need to declare the following external functions : FUNCTION integer SQ...
  • Sorting Datawindow
    Here's a script to sort datawindow rows when the column header is clicked as in windows explorer. Requirements : Column header should be...
  • Hiding Desktop and Taskbar
    With this tips you can easily hide the desktop and taskbar from the user 1. Declare win32 API module on Declare -> Local External FUnctio...
  • Faster Exist Checking in Oracle
    When performing checks in business logic to see if a record is used as part of a foreign key in a child table people often opt for the Selec...
  • Return Code on Application Exit
    Sometime when a PowerBuilder application is called by other program or a shell script, programmer want a return code after exiting the Power...
  • Avoiding "Double" Error Messages in DW Validation
    A common problem when setting up validation logic in ItemChanged is that two message get displayed. First, the intended message in ItemChang...
  • Keeping Column into Array
    With this simple tips you can keep all the column name on DataWindow into an array int colNum, numCols string colName[] numCols = Integer(dw...
  • Tracing on Running Application
    On PowerBuilder we can trace the running compiled application (*.exe) by running application with the /PBDEBUG option. application_name.exe...
  • Registering OCX Components in an Exe
    Having problems with OCX's which work fine in development and EXE on your machine but when you ship the EXE to a users machine and insta...

Categories

  • Database
  • DataWindow
  • PowerScript
  • Win32 API

Blog Archive

  • ▼  2008 (34)
    • ►  March (14)
    • ►  February (1)
    • ▼  January (19)
      • Avoiding "Double" Error Messages in DW Validation
      • Capturing Special Keys on your DataWindow
      • Center a Response Window
      • If Statements Using SQL
      • Run an Application Only Once
      • C/C++ Datatype Conversion
      • Registering OCX Components in an Exe
      • Get The Name of a Network Share
      • Get Volume Information
      • Mapping a Network Drive
      • Getting Active Directory
      • Getting Computer Name
      • Sending Key Press
      • Sending Hexadecimal Character to Printer
      • Calling an Internet Browser from Application
      • Getting Date Format from Windows Registry
      • Return Code on Application Exit
      • Sitemap
      • Privacy Policy
Powered by Blogger.

About Me

Unknown
View my complete profile