CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 1999
    Posts
    2

    diffent result from GetDiskFreeSpace()

    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


  2. #2
    Join Date
    Apr 1999
    Location
    Finland
    Posts
    68

    Re: diffent result from GetDiskFreeSpace()

    You could use GetLastError() to find out more detailed information about the function failure.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured