473,322 Members | 1,431 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,322 software developers and data experts.

Flexible dllimport

Hello,

I've got the following code:
namespace Test1
{
public struct stTest
{
public const string sDll = "C:\\Test1\\Test1.dll";

[DllImport(sDll)]
public static extern short Test1_Show(string Text);

[DllImport(sDll)]
public static extern short Test1_Add(string Text);

[DllImport(sDll)]
public static extern short Test1_Hide();
}
}

This all works, but I want the path to be changeable, something like:
public string sDll = ConfigurationSettings.AppSettings["DLL"]
but only constants are aloud.
The problem is, there are more Test1.dll's on the same PC and I want to switch between them.
Tnx,

--------------------------------
From: H. van Kooten

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>naaPgutx40CkPrjFURmukw==</Id>
Jul 21 '05 #1
1 1307
This all works, but I want the path to be changeable, something like:


You can use Reflection.Emit to generate them dynamicly

http://www.msjogren.net/dotnet/eng/s...dynpinvoke.asp

Mattias

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

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

Similar topics

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...
4
by: FrzzMan | last post by:
Hello, is there anyway to import unmanaged functions in a DLL file that locate somewhere out of the current path? Like this, when the app start, it'll locate the dll file, once it found the...
9
by: Ole Christensen | last post by:
I'm trying to make a sort of conditional compilation in my C# code because my app is intended to run on both a Pocket PC and on a normal desktop PC. My code uses a call to an API function that on...
1
by: H. van Kooten via .NET 247 | last post by:
Hello, I've got the following code: namespace Test1 { public struct stTest { public const string sDll = "C:\\Test1\\Test1.dll";
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.