Dave's Brain

Browse - programming tips - get windows handle from standard file

Date: 2008jan2
Platform: win32
Language: C

Q.  How can I get a Windows HANDLE from a standard C FILE * ?

A.  Like this:

main()
{
	FILE	*f;
	HANDLE	handle;

	f = fopen("myfile.txt", "r");
	handle = (HANDLE) _get_osfhandle(fileno(f));
}
What this info useful to you? You can donate to say thanks

Add a comment

Sign in to add a comment
Copyright © 2008-2010, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.