473,473 Members | 2,092 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

dllimport problem

greentings

I have a unmanaged dll that I need to use on my C# app. The problem is that
the dll may be in diferent places... The only way I have to get the location
of the dll is getting a key on the registry.

How can I use dllimport to a variable location?
or
There is another way to do this task?

I just need to load some methods from the dll...

Thanks in advance
Jun 25 '07 #1
3 1677
Diogo Alves wrote:
greentings

I have a unmanaged dll that I need to use on my C# app. The problem is
that the dll may be in diferent places... The only way I have to get the
location of the dll is getting a key on the registry.

How can I use dllimport to a variable location?
or
There is another way to do this task?

I just need to load some methods from the dll...

Thanks in advance
Hi,
How can I use dllimport to a variable location?
Unfortunately you cannot (not at runtime).
There is another way to do this task?
Yes.. but it's quite a lot more involved. It requires you to use the
LoadLibrary API to dynamically load the DLL into memory, then locate the
entry-point of the function(s) you require.

Once you have the addresses of the entry points, you then need to invoke
them, something I'll admit I don't know how to do in C#, having only done
this using C++.

Nothing creative immediately springs to mind, however I'm sure a quick
Google (and the help of Windows experts in this group!) will help with
that.

--
Tom Spink
University of Edinburgh
Jun 25 '07 #2
I would really like to see a example... I'm not finding a solution here
"Tom Spink" wrote:
Diogo Alves wrote:
greentings

I have a unmanaged dll that I need to use on my C# app. The problem is
that the dll may be in diferent places... The only way I have to get the
location of the dll is getting a key on the registry.

How can I use dllimport to a variable location?
or
There is another way to do this task?

I just need to load some methods from the dll...

Thanks in advance

Hi,
How can I use dllimport to a variable location?
Unfortunately you cannot (not at runtime).
There is another way to do this task?
Yes.. but it's quite a lot more involved. It requires you to use the
LoadLibrary API to dynamically load the DLL into memory, then locate the
entry-point of the function(s) you require.

Once you have the addresses of the entry points, you then need to invoke
them, something I'll admit I don't know how to do in C#, having only done
this using C++.

Nothing creative immediately springs to mind, however I'm sure a quick
Google (and the help of Windows experts in this group!) will help with
that.

--
Tom Spink
University of Edinburgh
Jun 25 '07 #3
Diogo Alves wrote:
I would really like to see a example... I'm not finding a solution here
"Tom Spink" wrote:
>Diogo Alves wrote:
greentings

I have a unmanaged dll that I need to use on my C# app. The problem is
that the dll may be in diferent places... The only way I have to get
the location of the dll is getting a key on the registry.

How can I use dllimport to a variable location?
or
There is another way to do this task?

I just need to load some methods from the dll...

Thanks in advance

Hi,
How can I use dllimport to a variable location?
Unfortunately you cannot (not at runtime).
There is another way to do this task?
Yes.. but it's quite a lot more involved. It requires you to use the
LoadLibrary API to dynamically load the DLL into memory, then locate the
entry-point of the function(s) you require.

Once you have the addresses of the entry points, you then need to invoke
them, something I'll admit I don't know how to do in C#, having only done
this using C++.

Nothing creative immediately springs to mind, however I'm sure a quick
Google (and the help of Windows experts in this group!) will help with
that.

--
Tom Spink
University of Edinburgh
Hi,

Please try googling! I typed "C# LoadLibrary" into Google, and got exactly
what you were looking for, as the first result:

http://www.codeproject.com/csharp/dyninvok.asp

Note: This solution may require some C knowledge.

--
Tom Spink
University of Edinburgh
Jun 25 '07 #4

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

Similar topics

5
by: caviar | last post by:
Hi, i'm having a problem with a native w32 dll. Everything is working fine except for one parameter which is defined as: --------------------------------------header file--- // short PASFIX...
15
by: Jim | last post by:
I am extremely frustrated. I am building c# application for a call center and am using a third party API to access some hardware. When develop and test my class using the windows console the...
2
by: Kurt Ng | last post by:
Hi, y'all. Can anyone help me on this problem? I'm working with a third-party C dll, and I'm having trouble importing into C# the dll's methods that return one of the dll's defined types,...
1
by: Whidbey Wave | last post by:
Hi , Of course sometimes, some of us have these weird DLLImport issues. I am using Net-snmp library from http://www.net-snmp.org. While creating a prototype as console application it worked fine,...
2
by: Brian Anderson | last post by:
Hello, is it possible to use DllImport to call a DLL in ASP.NET ? Or is it necessarry that my DLL has to be copied into \System32 ? My DLL is a native C++ 7.1 DLL (not managed, no COM, no...
1
by: Seth Gecko | last post by:
Hi I am developing a complex VB.Net Windows application for an engineering firm (don't ask me why they prefer VB.Net...). All the engineering calculations are done in FORTRAN which is compiled...
1
by: kardon33 | last post by:
Let me explain my problem, Im currently trying to use a Perl module that was built for a Windows OS that uses a .dll and .lib file. I have obtained the c header files that the modules were built...
1
by: JohnCox | last post by:
I have a simple Win32 DLL I wrote named "SimpleLib" that exports two functions. It is written in C++ and compiled with __stdcall (/Gz) and with the preprocessor definition _MBCS (not Unicode). ...
1
by: elke | last post by:
Hi, I want to use an unmanaged dll in C# .net and I'm having some troubles witch a function that should return an array. I'm new at this, so I don't know what I'm doing wrong. Here is some...
1
by: mrssuper | last post by:
Hey All, How do I declare a following types: char** unsigned char** in C# DllImport function?
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
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,...
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
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,...
1
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
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...
0
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 ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.