A Handy Guide To Handling Handles - CodeProject 10,872,446 members (72,805 online)
4.67/5 - 39 votes1 removedμ 4.33, σa 1.62 [?]
My vote of 4 Adi Shavit14-Jun-11 21:11 Good summary. Very helpful. Test could use a lot if improvement, but diagram is GREAT!
My vote of 4 Gokulnath00710-May-11 1:15 It is precise and good.
How to read no of row.. Shah Satish2-Dec-06 11:13 Hi!!
Re: How to read no of row.. Joseph M. Newcomer2-Dec-06 12:09 Files don't have "rows", they have "lines". A "row" would apply to a concept like a listbox, a list control, or a grid. Since you have not explained what is really in your file, it is hard to guess what you intended to do with it, or why i would be relevant.
The reason you are having trouble filling in the condition of the loop is that a for loop with a condition does not appear to make any sense for this purpose. I have a same problem! dSolariuM17-Oct-06 21:35 Hi,
Re: I have a same problem! Joseph M. Newcomer18-Oct-06 4:21 Why are you including the DDK? What version of the DDK are you including? What kind of error messages?
It is impossible to respond to a description this vague. Re: I have a same problem! dSolariuM19-Oct-06 8:24 I am using winxp ddk too access video memory and modem memory
Re: I have a same problem! Joseph M. Newcomer19-Oct-06 8:57 And please give the list of #include files showing where ntddk.h was included relative to other files.
Note that you can't access video memory or "modem memory" (whatever that is!) from user space. So are you writing a device driver? IStream to FILE * Fwzklmn7-Jun-06 14:23 Hi,
Thank's no fstream::attach any more Artem Alimarine23-Feb-06 5:36 I found the article usefull. However, the new version of the standard library does not allow to make a stream from a handle any more. The function fstream::attach and the friends are not available anymore. However, there still exists an fstream constructor that takes FILE.
Convert fd to handle? SteQve26-Oct-05 9:10 Hi!
If I have a fd and wants to convert it to a handle? (I have a fd and wants to call DeviceIoControl....) Re: Convert fd to handle? Joseph M. Newcomer26-Oct-05 16:10 What's an 'fd'? There are C library handles (small integers), FILE * objects, etc., but I have no idea what you mean by 'fd'. Re: Convert fd to handle? SteQve27-Oct-05 5:47 Oh! Sorry.
fd = file descriptor (small int) Re: Convert fd to handle? Joseph M. Newcomer27-Oct-05 14:16 I already describe this. Look at "C Library Handle" Be careful with _get_osfhandle under Windows Stitchyphish24-Aug-04 11:26 See KB99173 for details. Windows discourages the use of _get_osfhandle for converting between file descriptors and HANDLE types. Re: Be careful with _get_osfhandle under Windows Joseph M. Newcomer24-Aug-04 19:09 Interesting. What is odd is that no explanation of the "problems" is given. For example, if there is I/O going on through the C library handle, and reading or writing is done via the HANDLE, it is clear that the buffering issues will result in a skew of some sort in the data stream. But if the handles are merely translated before any I/O takes place, they should work OK. I've looked at the code and it is pretty trivial. I think it would have been a more informative document if it had not been so handwaving. Get a &quot;Fake&quot; Handle? Caio Proiete4-Aug-03 5:51 Hi Joseph, great article! Thanks!
Re: Get a &quot;Fake&quot; Handle? John M. Drescher4-Aug-03 6:54 My first thought is to allow CreateFile to create the file and use that handle instead of 555. You do not have to write anything to the file with WriteFile but you should close it with CloseHandle. John
Re: Get a &quot;Fake&quot; Handle? Caio Proiete4-Aug-03 7:38 Hi John, thank you for your comments.
Re: Get a &quot;Fake&quot; Handle? John M. Drescher4-Aug-03 7:57 Caio Proiete wrote:
Re: Get a &quot;Fake&quot; Handle? Joseph M. Newcomer14-Aug-03 7:17 This approach is bizarre, and I'm amazed it can be made to work at all. It strikes me as extremely fragile. The need to hook the APIs is definitely over the top as far as a piece of production code is concerned. The fact that the filename is hardwired is off-the-wall. This is very risky code.
Re: Get a &quot;Fake&quot; Handle? Caio Proiete14-Aug-03 9:00 Hi Joseph!
Re: Get a &quot;Fake&quot; Handle? Anonymously16-Aug-03 22:17 A great solution to a complicated problem! Sometimes all you need is a little creativity, don't let anyone tell you it's impossible. file handle to file name bfadi26-Feb-03 7:55 Hi,
Fadi Re: file handle to file name Joseph M. Newcomer26-Feb-03 9:07 There is a trick to including ntddk.h, which doesn't work with the latest ntddk.h.
context, so the compiler converted the name to a C++ name. Last Visit: 31-Dec-99 18:00 Last Update: 17-Sep-14 13:04Refresh12 Next »
Views 210,403
A Handy Guide To Handling Handles - CodeProject 10,872,446 members (72,805 online)
4.67/5 - 39 votes1 removedμ 4.33, σa 1.62 [?]
My vote of 4 Adi Shavit14-Jun-11 21:11 Good summary. Very helpful. Test could use a lot if improvement, but diagram is GREAT!
My vote of 4 Gokulnath00710-May-11 1:15 It is precise and good.
How to read no of row.. Shah Satish2-Dec-06 11:13 Hi!!
Re: How to read no of row.. Joseph M. Newcomer2-Dec-06 12:09 Files don't have "rows", they have "lines". A "row" would apply to a concept like a listbox, a list control, or a grid. Since you have not explained what is really in your file, it is hard to guess what you intended to do with it, or why i would be relevant.
The reason you are having trouble filling in the condition of the loop is that a for loop with a condition does not appear to make any sense for this purpose. I have a same problem! dSolariuM17-Oct-06 21:35 Hi,
Re: I have a same problem! Joseph M. Newcomer18-Oct-06 4:21 Why are you including the DDK? What version of the DDK are you including? What kind of error messages?
It is impossible to respond to a description this vague. Re: I have a same problem! dSolariuM19-Oct-06 8:24 I am using winxp ddk too access video memory and modem memory
Re: I have a same problem! Joseph M. Newcomer19-Oct-06 8:57 And please give the list of #include files showing where ntddk.h was included relative to other files.
Note that you can't access video memory or "modem memory" (whatever that is!) from user space. So are you writing a device driver? IStream to FILE * Fwzklmn7-Jun-06 14:23 Hi,
Thank's no fstream::attach any more Artem Alimarine23-Feb-06 5:36 I found the article usefull. However, the new version of the standard library does not allow to make a stream from a handle any more. The function fstream::attach and the friends are not available anymore. However, there still exists an fstream constructor that takes FILE.
Convert fd to handle? SteQve26-Oct-05 9:10 Hi!
If I have a fd and wants to convert it to a handle? (I have a fd and wants to call DeviceIoControl....) Re: Convert fd to handle? Joseph M. Newcomer26-Oct-05 16:10 What's an 'fd'? There are C library handles (small integers), FILE * objects, etc., but I have no idea what you mean by 'fd'. Re: Convert fd to handle? SteQve27-Oct-05 5:47 Oh! Sorry.
fd = file descriptor (small int) Re: Convert fd to handle? Joseph M. Newco
mer27-Oct-05 14:16 I already describe this. Look at "C Library Handle" Be careful with _get_osfhandle under Windows Stitchyphish24-Aug-04 11:26 See KB99173 for details. Windows discourages the use of _get_osfhandle for converting between file descriptors and HANDLE types. Re: Be careful with _get_osfhandle under Windows Joseph M. Newcomer24-Aug-04 19:09 Interesting. What is odd is that no explanation of the "problems" is given. For example, if there is I/O going on through the C library handle, and reading or writing is done via the HANDLE, it is clear that the buffering issues will result in a skew of some sort in the data stream. But if the handles are merely translated before any I/O takes place, they should work OK. I've looked at the code and it is pretty trivial. I think it would have been a more informative document if it had not been so handwaving. Get a &quot;Fake&quot; Handle? Caio Proiete4-Aug-03 5:51 Hi Joseph, great article! Thanks!
Re: Get a &quot;Fake&quot; Handle? John M. Drescher4-Aug-03 6:54 My first thought is to allow CreateFile to create the file and use that handle instead of 555. You do not have to write anything to the file with WriteFile but you should close it with CloseHandle. John
Re: Get a &quot;Fake&quot; Handle? Caio Proiete4-Aug-03 7:38 Hi John, thank you for your comments.
Re: Get a &quot;Fake&quot; Handle? John M. Drescher4-Aug-03 7:57 Caio Proiete wrote:
Re: Get a &quot;Fake&quot; Handle? Joseph M. Newcomer14-Aug-03 7:17 This approach is bizarre, and I'm amazed it can be made to work at all. It strikes me as extremely fragile. The need to hook the APIs is definitely over the top as far as a piece of production code is concerned. The fact that the filename is hardwired is off-the-wall. This is very risky code.
Re: Get a &quot;Fake&quot; Handle? Caio Proiete14-Aug-03 9:00 Hi Joseph!
Re: Get a &quot;Fake&quot; Handle? Anonymously16-Aug-03 22:17 A great solution to a complicated problem! Sometimes all you need is a little creativity, don't let anyone tell you it's impossible. file handle to file name bfadi26-Feb-03 7:55 Hi,
Fadi Re: file handle to file name Joseph M. Newcomer26-Feb-03 9:07 There is a trick to including ntddk.h, which doesn't work with the latest ntddk.h.
context, so the compiler converted the name to a C++ name. Last Visit: 31-Dec-99 18:00 Last Update: 17-Sep-14 13:04Refresh12 Next »
Views 210,403