Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

File I/O problem in Visual C++ using "OpenFile"

It seems that function "OpenFile" doesn't work in Visual C++ while it works in CVI.
Here is a simple testing program.

#include
#include
#include
void main()
{
int hFile;
hFile = OpenFile ("d:\\temp.txt", VAL_READ_WRITE, VAL_TRUNCATE, VAL_ASCII);
if (hFile == -1)
{
MessagePopup("Error", "File not opened");
}
else
{
const char buf[] = "Just Testing.";
WriteFile (hFile, buf, strlen(buf));
MessagePopup("Msg", "File opened and written.");
CloseFile (hFile);
}
}

When this program runs in Labwindows/CVI, the result is "File opened and written" and the buf is written to file. But when it runs in Visua
l C++6.0, the result is "File not Opened".

It seemed that "OpenFile" doesn't work in Visual C++, while "fopen" works.

Does anybody know why?
Thanks.
0 Kudos
Message 1 of 3
(3,049 Views)
That is strange behavior. I suggest posting this on the LabWindows/CVI forum to get the best answer to this question.

- Elton
0 Kudos
Message 2 of 3
(3,049 Views)
Hello

See this post.

Bilal Durrani
NI
Bilal Durrani
NI
0 Kudos
Message 3 of 3
(3,049 Views)