473,378 Members | 1,605 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Getting CreateFile handle in managed code

I'm having trouble getting a handle returned from the following code
within a managed class:

HANDLE m_hSerialComm = CreateFile("\\\\.\\COM1\0\0\0",
GENERIC_READ|GENERIC_WRITE, 0, 0, OPEN_EXISTING,
FILE_FLAG_NO_BUFFERING, 0);

It works fine in non-managed code but I get a '{void}' returned when run
within managed code. I'm wondering if that's actually the problem or if
there is something else I'm missing... If it is the problem, then what's
the best solution?

Thanks
Steve
Nov 17 '05 #1
1 1824
Steve,
I'm having trouble getting a handle returned from the following code
within a managed class:

HANDLE m_hSerialComm = CreateFile("\\\\.\\COM1\0\0\0",
GENERIC_READ|GENERIC_WRITE, 0, 0, OPEN_EXISTING,
FILE_FLAG_NO_BUFFERING, 0);

It works fine in non-managed code but I get a '{void}' returned when run
within managed code. I'm wondering if that's actually the problem or if
there is something else I'm missing... If it is the problem, then what's
the best solution?


There shouldn't be a problem. I believe what you're seeing is that when
working in the mixed mode debugger it has "issues" displaying the values of
certain things (like handle values, which are just void* in essence).
--
Tomas Restrepo
to****@mvps.org
http://www.winterdom.com/
Nov 17 '05 #2

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

Similar topics

1
by: Chuck Rittersdorf | last post by:
Hi There I am having a problem using the win32 API from VB6. I am trying to send a command string to a printer(zebra TLP 2742) on LPT1 using the folowing API functions CreateFile and...
0
by: Nitin Narang | last post by:
I have a piece of code which is moved to .NET VC7 recently from VC6 and there has been an apparent change in behavior using CreateFile/Writefile functionality. I am creating a file on a shared...
3
by: red | last post by:
I have this: using System; using System.Runtime.InteropServices; using System.Text; class FileReader { const uint GENERIC_READ = 0x80000000; const uint OPEN_EXISTING = 3;
1
by: David | last post by:
Hi, I have a problem in getting the status of the modem. Here is my code: HANDLE hfile; DCB dcb; hfile = CreateFile("BCM V.92 56K Modem", GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL); ...
12
by: Terry Olsen | last post by:
I'm trying to create a disk image of a floppy disk. Since I can't open the device using the system.io methods, i'm trying to use the CreateFile API to get a handle for me. But the call fails...
2
by: Bob Gray | last post by:
Hi, Can anyone explain how P/Invoke is able to cast the 32-bit HANDLE value returned from CreateFile (for example) to a SafeFileHandle object? Have a look at this code snippet from the .NET...
1
by: ranju | last post by:
I am trying to spawn a process (say an exe file) with different user crendentials than that of the current user. 1) Called LogonUserEx() to logon the user and recieve a handle to the token that...
2
by: Lou | last post by:
i am using CreateFile in a VB6 app but it doesn't work in VB .NET COM dll. hGpiFile = CreateFile("\\.\BLIO1", GENERIC_READ Or GENERIC_WRITE, 0, gblSecurity, OPEN_EXISTING, 0, 0) I get an error...
2
by: Sin Jeong-hun | last post by:
Below is the code in Managed C++. It was originally written in C, and posted somewhere around the Internet (I forgot where I copied this code), and I changed it into Managed C++. This code returnes...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.