473,722 Members | 2,484 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to get Win32 handle from FILE*

PLS
I'm writing native C++ using VS2005.

I have a FILE* for a file opened with fopen. I want to get the WIN32
file handle for this file so I can call GetFileTime on it.

I can get the descriptor number with _fileno, but there doesn't seem to
be a function to give me the handle from the descriptor number.

Any ideas how I can do this?

Thanks,
++PLS
Nov 29 '07 #1
1 4629
Use _fileno followed by _get_osfhandle.

Regards,

Brian Muth

"PLS" <no****@nowhere .comwrote in message news:MP******** *************** *@msnews.micros oft.com...
I'm writing native C++ using VS2005.

I have a FILE* for a file opened with fopen. I want to get the WIN32
file handle for this file so I can call GetFileTime on it.

I can get the descriptor number with _fileno, but there doesn't seem to
be a function to give me the handle from the descriptor number.

Any ideas how I can do this?

Thanks,
++PLS
Nov 29 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
105819
by: Dave | last post by:
Hi, I have done some research, trying to Clear The Screen in java code. The first option was the obv: system.out.print("\n\n\n\n\n\n\n\n\n\n\n\n"); then i heard about this method: System.out.print((char)27 + "[2J");
2
14357
by: Jorgen Grahn | last post by:
I couldn't think of a good solution, and it's hard to Google for... I write python command-line programs under Win2k, and I use the bash shell from Cygwin. I cannot use Cygwin's python package because of a binary module which has to be compiled with Visual C 6. My scripts start with a '#!/usr/bin/env python' shebang, as God intended. Now, I assume I can make cmd.exe run foo.py by asociating *.py with the python interpreter.
28
2668
by: Grant Edwards | last post by:
I finally figured out why one of my apps sometimes fails under Win32 when it always works fine under Linux: Under Win32, the pickle module only works with a subset of floating point values. In particular the if you try to dump/load an infinity or nan value, the load operation chokes: Under Linux: $ python
0
5136
by: rtm | last post by:
I am interested in running a process with a timeout. Also I'm interested in analyzing the output of this process. Under Unix, the solution is described clearly in the Perl Cookbook "16.10: Communicating between related processes" and 16.24 "Timing out an Operation". Enclosed below is an example showing what I want to do under Unix. I need to do this under Windows XP. As others have pointed out "alarm" works under 5.8+ and fork...
2
2952
by: mlc | last post by:
I have a server (in win32 C++, TCP) that listens and accepts socket calls, then via CreateProcess and handle inheritence over the command line starts up a process to handle the client request. Is there any way I can write a C# application that can also handle the client request from a open handle from a win32 process in a like manner? (No, I can't rewrite the server in C#, or change it in any fundmental way, I can however replace the...
2
2715
by: Shawn Anderson | last post by:
Anyone know how I can get a Win32 HANDLE from a StreamReader or StreamWriter? I want to work with some I/O using Win32 APIs, but I would like to attach the I/O to a .NET Stream class. Any suggestions? Thanks Shawn
0
2978
by: Mythran | last post by:
I wrote some code that is supposed to enumerate through the specified file's win32 resources and return a string-array of all icon names. When it runs, it returns a string-array with a bunch of numbers in sequential order (1-55 when ran against iexplore.exe). When I open up iexplore.exe in Visual Studio, I see 23 icons. Each icon has 1 or more sizes of the icon...I'm assuming that there are, in fact, 55 icon resources in iexplore.exe,...
0
1382
by: David | last post by:
I've just recently read several articles that state that the only way to write "sparse zeros" to an NTFS5 sparse file is to use Win32 DeviceIoControl with FSCTL_SET_ZERO_DATA in order to specify what ranges in the file are sparse zeros. However, it appears that the following steps also work when creating a new sparse file. First, using Win32 (via .NET 1.1 pinvoke), I ... CreateFile (returns a handle)
2
3097
by: Steve Richter | last post by:
using vs2005, the wizard created a c++ forms project for me. Now in the form1.h file I have a menu item click handler that I would like to add some win32 api code to: private: System::Void tapeToolStripMenuItem_Click( System::Object^ sender, System::EventArgs^ e) { HANDLE hTape = CreateFile( "\\\\.\\TAPE0", GENERIC_READ |
0
8863
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8739
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9384
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9088
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8052
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4502
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4762
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2602
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2147
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.