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

how to load an unmanaged DLL

dev
Good Morning,
First, I must say that I'm completly newbie about C# and .NET, nevertlessy
my company put me on work on a C# projects...

So I'm here to ask for help:

I have an unmanaged DLL that export a function.

The function is (as declare in VB software that import it):
Private Declare Function SCardComand Lib "SCARD32"
(Handle As Long,
ByVal cmd As String,
CmdLen As Long,
ByVal DataIn As String,
DataInLen As Long,
ByVal DataOut As String,
DataOutLen As Long) As Long

As you can see we have a mix of input and output parameters. How can I:
1) Import/Declare this function in C#?
2) Pass the equivalent of a C++ NULL pointer to the function
3) Pass the equivalent of a long* to the function

Thanks for whater help you can provide me.

Dev

Nov 15 '05 #1
2 2389
1) Import/Declare this function in C#?
Probably something like this

[DllImport("scard32.dll")]
static extern int SCardComand(ref IntPtr Handle, string cmd, ref int
mdLen As Long, string DataIn, ref int DataInLen, StringBuilder
DataOut, ref int DataOutLen);

2) Pass the equivalent of a C++ NULL pointer to the function
It depends on the parameter type, but usually with the null keyword or
IntPtr.Zero.

3) Pass the equivalent of a long* to the function


ref int (or out int if it's an out-only argument).

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 15 '05 #2
dev
Thank you very much Matthias,
I didn't know about the out param or StringBuilder, now I go try...

Bye

Dev
"Mattias Sjögren" <ma********************@mvps.org> ha scritto nel messaggio
news:up**************@TK2MSFTNGP12.phx.gbl...
1) Import/Declare this function in C#?


Probably something like this

[DllImport("scard32.dll")]
static extern int SCardComand(ref IntPtr Handle, string cmd, ref int
mdLen As Long, string DataIn, ref int DataInLen, StringBuilder
DataOut, ref int DataOutLen);

2) Pass the equivalent of a C++ NULL pointer to the function


It depends on the parameter type, but usually with the null keyword or
IntPtr.Zero.

3) Pass the equivalent of a long* to the function


ref int (or out int if it's an out-only argument).

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Nov 15 '05 #3

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

Similar topics

1
by: Kevin Lewis | last post by:
Is there .NET framework code that I can call from an assembly (.dll), that will load the settings of a configuration file into the .NET framework. For example you can set up Switches and...
3
by: lallous | last post by:
Hello I'm new to C# and wonder if it is possible, as it is possible in C++, to dynamically load a DLL and use it in C#. The dll is written in C++ (unmanaged) and has the following export: ...
1
by: Arun | last post by:
Hi, I've got a managed class , inside which I'm instantiating an unmanaged class. If that class has some virtual methods, then while debugging I couldn't jump into the source of that virtual...
12
by: Sharon | last post by:
I’m wrote a small DLL that used the FreeImage.DLL (that can be found at http://www.codeproject.com/bitmap/graphicsuite.asp). I also wrote a small console application in C++ (unmanaged) that uses...
3
by: Kanaiya | last post by:
hello i get some answers from previous messages but i am not able to get proper idea in vc++ case. can u explain me proper. bye.
2
by: Alex Sedow | last post by:
Hello group! How to load assembly from GAC using unmanaged C++? I want load assembly into memory or get path to file on disk. Alex.
0
by: Eric Twietmeyer | last post by:
Hello, Am I mistaken in thinking that if I have a mc++ dll that I should be able to link against it (so long as it has exported symbols via declspec(dllexport)) in an unmanaged application? I...
1
by: Sparhawk | last post by:
Hi, my company is going to migrate a large VC++ application to .NET to make use of Windows Forms (the old class library is not updated any more). We are not planning to migrate the rest of the...
0
by: xievvv | last post by:
How to dynamically load a .net dll from unmanaged c++ code? Thanks in advance!
8
by: Joe Withawk | last post by:
I have a solution consisting of a c# project as win application and a c++ project as classlibrary. Both are .net 2.0 The classlibrary handles some loading of quicktime movies, but that should not...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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,...
0
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...

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.