473,804 Members | 3,081 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

"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::CreateFi le'
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 3164
"Lou" <lo********@com cast.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::CreateFi le' 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::CreateFi le'
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
5813
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 held in memory and therefore fast, without risk of damaging real files, and with none of the messiness of leftover files after testing. Googling the archives and the web suggests that only I and Remy Blank have done much along these lines. I...
5
3297
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
10835
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, but I can't open the device using File.Open. I get the following error: An unhandled exception of type 'System.ArgumentException' occurred in mscorlib.dll Additional information: Illegal characters in path.
4
17947
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
5634
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 "c:\inetpub\wwwroot\MyWeb\Resources\Templates\MyPage.Html" is denied. at System.IO.__Error.WinIOError(Int32 errorCode, String str) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access,
5
1200
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 UNICODE entry("lstrlenW"), #else
9
7136
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 when I tried the program on the Win98 system it will be running on, I get the following error: Cast from string "2076719" to type 'Long' is not valid I am not sure why I only get this error on the Win98 system or how to go about correcting...
3
7079
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; NewLineIdr = 0x0000; I need it to use it in my saving procedure because I need to create tabullary text file. But my effort usually results in one or two small
25
3021
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 MyClass:IDisposable
0
9575
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10564
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10320
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10073
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9134
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7609
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4288
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3806
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2981
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.