Download MetaTrader 5
To add comments, please log in or register
Deposit to your account via PayPal
Charles Adriano
465
Charles Adriano 2014.03.22 18:31 

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
28624
Alain Verleyen 2014.03.22 19:29  
Strings are now Unicode and no more Ansi. You have to adapt your code accordingly. Use GetVolumeInformationW instead of GetVolumeInformationA.
Charles Adriano
465
Charles Adriano 2014.03.22 20:13  
:)

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


charles

/
To add comments, please log in or register