Click here to Skip to main content
15,898,035 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Ignore this - I don't need any assistance Pin
Cedric Moonen1-Feb-08 0:07
Cedric Moonen1-Feb-08 0:07 
GeneralRe: can anybody help me out Pin
CPallini31-Jan-08 23:01
mveCPallini31-Jan-08 23:01 
GeneralRe: can anybody help me out Pin
Cedric Moonen31-Jan-08 23:08
Cedric Moonen31-Jan-08 23:08 
GeneralRe: can anybody help me out Pin
CPallini31-Jan-08 23:21
mveCPallini31-Jan-08 23:21 
GeneralRe: can anybody help me out Pin
Iain Clarke, Warrior Programmer31-Jan-08 23:13
Iain Clarke, Warrior Programmer31-Jan-08 23:13 
GeneralRe: can anybody help me out Pin
CPallini31-Jan-08 23:45
mveCPallini31-Jan-08 23:45 
QuestionIs there a Windows API or a method which can convert FILE* to HANDLE of a file or convert HANDLE to FILE* ?? Pin
Jude Deng31-Jan-08 22:13
Jude Deng31-Jan-08 22:13 
GeneralRe: Is there a Windows API or a method which can convert FILE* to HANDLE of a file or convert HANDLE to FILE* ?? Pin
Iain Clarke, Warrior Programmer31-Jan-08 22:53
Iain Clarke, Warrior Programmer31-Jan-08 22:53 
I made a line
FILE *p = fopen ("foo", "rw");

and kept debugging into functions until I found the C runtime using an array of information called _osfhnd which stored the mapping between stream opened by _tsopen and HANDLE. This stream is the _file member of FILE.


_get_osfhandle

http://msdn2.microsoft.com/en-us/library/ks2530z6.aspx[^]

The below code omits any error checking whatsoever....

HANDLE FileToHandle (FILE *f)
{
    return (HANDLE)(f->_file);
}


There are lots of reasons to be careful - if you're not in control of the FILE *, what's to stop them closing it without you knowing, etc.


Enjoy!

Iain.
GeneralRe: Is there a Windows API or a method which can convert FILE* to HANDLE of a file or convert HANDLE to FILE* ?? Pin
Jude Deng1-Feb-08 19:01
Jude Deng1-Feb-08 19:01 
GeneralRe: Is there a Windows API or a method which can convert FILE* to HANDLE of a file or convert HANDLE to FILE* ?? Pin
Jude Deng1-Feb-08 22:03
Jude Deng1-Feb-08 22:03 
GeneralRe: Is there a Windows API or a method which can convert FILE* to HANDLE of a file or convert HANDLE to FILE* ?? Pin
Iain Clarke, Warrior Programmer2-Feb-08 12:32
Iain Clarke, Warrior Programmer2-Feb-08 12:32 
GeneralRe: Is there a Windows API or a method which can convert FILE* to HANDLE of a file or convert HANDLE to FILE* ?? Pin
Jude Deng2-Feb-08 13:04
Jude Deng2-Feb-08 13:04 
Generaledit box issue Pin
Chandrasekharan P31-Jan-08 19:53
Chandrasekharan P31-Jan-08 19:53 
GeneralRe: edit box issue Pin
Hamid_RT31-Jan-08 19:54
Hamid_RT31-Jan-08 19:54 
GeneralRe: edit box issue Pin
Chandrasekharan P31-Jan-08 20:35
Chandrasekharan P31-Jan-08 20:35 
GeneralRe: edit box issue Pin
Hamid_RT31-Jan-08 21:19
Hamid_RT31-Jan-08 21:19 
GeneralRe: edit box issue Pin
Chandrasekharan P31-Jan-08 22:43
Chandrasekharan P31-Jan-08 22:43 
GeneralRe: edit box issue Pin
Hamid_RT31-Jan-08 23:08
Hamid_RT31-Jan-08 23:08 
GeneralRe: edit box issue Pin
Cedric Moonen31-Jan-08 23:14
Cedric Moonen31-Jan-08 23:14 
GeneralRe: edit box issue Pin
Hamid_RT1-Feb-08 0:55
Hamid_RT1-Feb-08 0:55 
GeneralRe: edit box issue Pin
Iain Clarke, Warrior Programmer31-Jan-08 22:56
Iain Clarke, Warrior Programmer31-Jan-08 22:56 
GeneralRe: edit box issue Pin
Chandrasekharan P31-Jan-08 23:54
Chandrasekharan P31-Jan-08 23:54 
GeneralRe: edit box issue Pin
Iain Clarke, Warrior Programmer1-Feb-08 0:20
Iain Clarke, Warrior Programmer1-Feb-08 0:20 
GeneralRe: edit box issue Pin
Chandrasekharan P4-Feb-08 0:08
Chandrasekharan P4-Feb-08 0:08 
GeneralRe: edit box issue Pin
Iain Clarke, Warrior Programmer4-Feb-08 1:01
Iain Clarke, Warrior Programmer4-Feb-08 1:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.