473,385 Members | 2,028 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,385 software developers and data experts.

"CreateFile" APIl

Lou
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 message:
A call to PInvoke function 'BlastronicsGpi!BlastronicsGpi.cGpi::CreateFile'
has unbalanced the stack. This is likely because the managed PInvoke
signature does not match the unmanaged target signature. Check that the
calling convention and parameters of the PInvoke signature match the target
unmanaged signature.

Same code works great in VB6?

-Lou
Oct 2 '07 #1
2 3149
"Lou" <lo********@comcast.netschrieb
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 message:
A call to PInvoke function
'BlastronicsGpi!BlastronicsGpi.cGpi::CreateFile' has unbalanced the
stack. This is likely because the managed PInvoke signature does not
match the unmanaged target signature. Check that the calling
convention and parameters of the PInvoke signature match the target
unmanaged signature.

Same code works great in VB6?
You mustn't use the same code because it's a different language.
Probably you took the VB6 API declaration.
Armin
Oct 2 '07 #2
Looks like your Pinvoke defn is wrong. Check pinvoke.net for the right
signature.

http://pinvoke.net/default.aspx/kern...reateFile.html

--
Rgds,
Anand
http://www.dotnetindia.com
"Lou" wrote:
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 message:
A call to PInvoke function 'BlastronicsGpi!BlastronicsGpi.cGpi::CreateFile'
has unbalanced the stack. This is likely because the managed PInvoke
signature does not match the unmanaged target signature. Check that the
calling convention and parameters of the PInvoke signature match the target
unmanaged signature.

Same code works great in VB6?

-Lou
Oct 2 '07 #3

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

Similar topics

9
by: Peter Hansen | last post by:
The term "mock filesystem" refers to code allowing unit or acceptance tests to create, read and write, and manipulate in other ways "virtual" files, without any actual disk access. Everything is...
5
by: pekka niiranen | last post by:
Does anybody know Python recipe for changing the date of the directory or files in W2K to current date and time? In UNIX shell command "touch" does it. -pekka-
2
by: Karl Koscher | last post by:
I'm trying to communicate with a USB device using C#. I'm able to determine the device path using P/Invoke and SetupDiGetClassDevs, SetupDiEnumDeviceInterfaces, and SetupDiGetDeviceInterfaceDetail,...
4
by: craigkenisston | last post by:
Hi, How can I open a file with the FILE_FLAG_NO_BUFFERING using .net just like in the win32 days ?
1
by: VB Programmer | last post by:
When I run this line: Dim sw As New System.IO.StreamWriter(strFileName) I get this error: System.UnauthorizedAccessException: Access to the path...
5
by: active | last post by:
In windows XP and VB.NET should the "W" functions in the Windows API be used or should the "A" functions be used I'm looking at a type library and see things like the following: #ifdef...
9
by: rsine | last post by:
I have developed a program that sends a command through the serial port to our business system and then reads from the buffer looking for a number. Everything worked great on my WinXP system, but...
3
by: MIUSS | last post by:
Hello everyone! I got a problem with creating new line... I tried this: lstrcpy(NewLineIdr, TEXT("\r\n")); I already tried this: NewLineIdr = 0x000D; NewLineIdr = 0x000A;...
25
by: Koliber (js) | last post by:
sorry for my not perfect english i am really f&*ckin angry in this common pattern about dispose: ////////////////////////////////////////////////////////// Public class...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.