Download MetaTrader 5

call GetVolumeInformationA no return values

To add comments, please log in or register
Charles Adriano
468
Charles Adriano  

Hi all...

please tell me what's wrong in this code?


//+------------------------------------------------------------------+
//| GetVolumeInformation.mq4 |
//+------------------------------------------------------------------+
#property copyright "Copyright © free"
#property link "free"
#property strict
#property show_inputs

#import "kernel32.dll"
bool GetVolumeInformationA (string lpRootPathName,
string lpVolumeNameBuffer,
int nVolumeNameSize,
int &lpVolumeSerialNumber[],
int &lpMaximumComponentLength[],
int &lpFileSystemFlags[],
string lpFileSystemNameBuffer,
int nFileSystemNameSize);
#import

extern string DriveLetter = "C";

void start()
{
string sNameDisk = DriveLetter + ":\\";
string sNameBuffer = " ";
string sSysNameBuffer = " ";
int dwVSNumber[1] = {0};
int dwMCLength[1] = {0};
int dwFileSF[1] = {0};
bool FunctionOk = GetVolumeInformationA(sNameDisk,
sNameBuffer,
StringLen(sNameBuffer) + 1,
dwVSNumber,
dwMCLength,
dwFileSF,
sSysNameBuffer,
StringLen(sSysNameBuffer) + 1);
if (FunctionOk)
Comment("NameBuffer: \'", sNameBuffer,"\'",
"\nSysNameBuffer: \'", sSysNameBuffer,"\'",
"\nSysNameBuffer: ", sSysNameBuffer,
"\nVSNumber = ", dwVSNumber[0],
"\nMCLength = ", dwMCLength[0],
"\nFileSF = ", dwFileSF[0]);
else
Comment("GetVolumeInformationA not all the requested information was retrieved!"
"\nNameBuffer: \'", sNameBuffer,"\'",
"\nSysNameBuffer: \'", sSysNameBuffer,"\'",
"\nVSNumber = ", dwVSNumber[0],
"\nMCLength = ", dwMCLength[0],
"\nFileSF = ", dwFileSF[0]);

return;
}



maybe a import definition or call parameters?


http://msdn.microsoft.com/en-us/library/windows/desktop/aa364993%28v=vs.85%29.aspx


I need to get a serial number of Hard Disk, but this function not work.

Any idea?

charles

Alain Verleyen
Moderator
32372
Alain Verleyen  
Strings are now Unicode and no more Ansi. You have to adapt your code accordingly. Use GetVolumeInformationW instead of GetVolumeInformationA.
Charles Adriano
468
Charles Adriano  
:)

Work fine now... a lot of thanks...


charles

To add comments, please log in or register