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 2 2397 1) Import/Declare this function in C#?
Probably something like this
[DllImport("scar d32.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.
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.o rg> ha scritto nel messaggio
news:up******** ******@TK2MSFTN GP12.phx.gbl... 1) Import/Declare this function in C#?
Probably something like this
[DllImport("scar d32.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. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 TraceListeners through config settings
such as:
<system.diagnostics>
<switches>
<add name="MySwitch" value="31" />
</switches>
<trace>
|
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:
int test(void);
and the code resides in test.dll
|
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 method. I can go into the
source of other non virtual methods of the same unmanaged class.
Surprisingly this happens only in one condition: Only when I...
|
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 the
DLL above.
Now the application, together with the above DLL’s is successfully loading a
TIF image file (62992 x 113386 Pixels, Huffman RLE...
|
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.
| |
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.
|
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 am currently testing this and it fails. I have a native, unmanaged test
application that links against my mc++ dll with a function entry point....
|
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 code which works
well.
I understand the basic concept: our code is unmanaged, Windows Forms
is Managed and Unmanaged may not call Managed code. I...
|
by: xievvv |
last post by:
How to dynamically load a .net dll from unmanaged c++ code?
Thanks in advance!
|
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 be relevant.
On my development machine I build the exe and dll and run the exe which has
a reference to the dll. At some point it uses featured in...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
| |
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...
|
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. ...
|
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...
|
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...
|
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...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |