From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
12-15-2006 02:28 PM
12-15-2006 04:41 PM
I found that I have to resort to the Windows SDK functions. So here is a wrapper I made that returns the file size as a real number to show total number of bytes for a file. I found that another like had given me the basic answer, but I have to resort to file handles. So, I take no credit for this code, as it is from another post in the forum (with a small change:
#include <windows.h>
double GetLargeFileSize(char *sFileName)
{
double dSize;
LARGE_INTEGER lpNumBytes;
SECURITY_ATTRIBUTES saAttr;
HANDLE hFileHandle = NULL;
#define E32 4294967296.0 //2^32
hFileHandle = CreateFile(sFileName, GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFileHandle == INVALID_HANDLE_VALUE)
{
dSize = -2.0;
}
else
{
if (GetFileSizeEx(hFileHandle, &lpNumBytes) > 0)
{
dSize = lpNumBytes.HighPart*E32 + lpNumBytes.LowPart;
}
else
{
dSize = -1.0;
}
CloseHandle(hFileHandle);
}
return dSize;
}
I return the negative umbers as error indicators so the caller knows that it failed in one of two aspects. Thanks and cheers from the desert.
12-18-2006 03:45 AM
@RorySmash wrote:
I found that I have to resort to the Windows SDK functions. So here is a wrapper I made that returns the file size as a real number to show total number of bytes for a file. I found that another like had given me the basic answer, but I have to resort to file handles. So, I take no credit for this code, as it is from another post in the forum (with a small change:
#include <windows.h>
double GetLargeFileSize(char *sFileName)
{double dSize;
LARGE_INTEGER lpNumBytes;
SECURITY_ATTRIBUTES saAttr;
HANDLE hFileHandle = NULL;#define E32 4294967296.0 //2^32
hFileHandle = CreateFile(sFileName, GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFileHandle == INVALID_HANDLE_VALUE)
{
dSize = -2.0;
}
else
{
if (GetFileSizeEx(hFileHandle, &lpNumBytes) > 0)
{
dSize = lpNumBytes.HighPart*E32 + lpNumBytes.LowPart;
}
else
{
dSize = -1.0;
}
CloseHandle(hFileHandle);
}
return dSize;
}I return the negative umbers as error indicators so the caller knows that it failed in one of two aspects. Thanks and cheers from the desert.
First I think this should have been in the LabWindows/CVI board.
Second, it's quite liklely that CVI 8.x adds int64 support just as LabVIEW did with version 8.0.
Rolf Kalbermatter
12-18-2006 10:15 AM
Sorry,
I thought I did post it in the LabWindows/CVi area. I apologize for the mistake. Thanks for the help.