LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How can i get file information from a file referenced only by filehandle

Hi,
 
I have a global function which is searching for a string in a file, referenced by an integer filehandle. If the function doesn't find the string, I want to post a message including the filename. How can I get file information from a filehandle?
0 Kudos
Message 1 of 3
(2,973 Views)

In my opinion you can't... the file handle is an identifier that is unique during program execution, but is dinamically cteated when you open the file depending on how much files are open at that moment (i.e. opening the same file in different moments can drive to different file handles if in the time elapsed you have opened / closed other files; similarly, the same file handle can refer to different physical files in different moments Smiley Surprised ).

One possible solution could be to receive from the caller both the file handle and its name, or to demand to the caller the responsibility of warning the operator of the failed search.



Message Edited by Roberto Bozzolo on 06-19-2008 06:32 PM


Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 3
(2,969 Views)

Well, actually I must partially correct myself: while I'm not aware of a method to obtain what you want from CVI file handles, I made a search on MSDN finding this thread that may be of some help to you.

According to that document, if you use SDK CreateFile function to open the file (and conseguently SDK functions to read / write to it Smiley Surprised ) you may derive the filename starting from the file handle. I made a simple project that uses the code supplied in that MSDN page to obtain the filename: take a lok at the attached project if you want to consider this way to solve your problem.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 3 of 3
(2,954 Views)