cris
May 20th, 1999, 09:43 AM
I must use VB4-16Bit to contro a machine. For the filehandling I want to get free diskspace. In VB4-16Bit and the Kernel.DLL is no function like GetDiskFreeSpace in Kernel32.DLL. So I wrote i small program to get the free diskspace and put the result into a textfile.
[ccode]
#include <windows.h>
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow )
{
//lpCmdLine is like: a: c:\temp\space.txt
//and so locking for free diskspace on a: and write the result into c:\temp\space.txt
char buffer[32];
lpCmdLine[2] =0;
DWORD SectorsPerCluster, BytesPerSector, NumberOfFreeClusters, TotalNumberOfClusters;
if(GetDiskFreeSpace(lpCmdLine, &SectorsPerCluster, &BytesPerSector, &NumberOfFreeClusters, &TotalNumberOfClusters))
{
//no error
ltoa(SectorsPerCluster * BytesPerSector * NumberOfFreeClusters, buffer, 10);
}
else
{
//error
strcpy(buffer, "-1");
}
//Ergebnis in INI-Datei schreiben
WritePrivateProfileString("global", "FreeDiskSpace",buffer,lpCmdLine+3);
return 0;
}
[\ccode]
But there is as diffence in result. When I start the program in the DOS-box (or VB4-16bit-program) the result is -1, in start->run-box then result is correct.
What's the diffence in the function GetDiskFreeSpace() when started in DOS-box and started in Exlorer?
Thanks
Cris
[ccode]
#include <windows.h>
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow )
{
//lpCmdLine is like: a: c:\temp\space.txt
//and so locking for free diskspace on a: and write the result into c:\temp\space.txt
char buffer[32];
lpCmdLine[2] =0;
DWORD SectorsPerCluster, BytesPerSector, NumberOfFreeClusters, TotalNumberOfClusters;
if(GetDiskFreeSpace(lpCmdLine, &SectorsPerCluster, &BytesPerSector, &NumberOfFreeClusters, &TotalNumberOfClusters))
{
//no error
ltoa(SectorsPerCluster * BytesPerSector * NumberOfFreeClusters, buffer, 10);
}
else
{
//error
strcpy(buffer, "-1");
}
//Ergebnis in INI-Datei schreiben
WritePrivateProfileString("global", "FreeDiskSpace",buffer,lpCmdLine+3);
return 0;
}
[\ccode]
But there is as diffence in result. When I start the program in the DOS-box (or VB4-16bit-program) the result is -1, in start->run-box then result is correct.
What's the diffence in the function GetDiskFreeSpace() when started in DOS-box and started in Exlorer?
Thanks
Cris