I am new to C #, and wanted to do the following: I have the dllimport class being used in another class. The problem is this, I want to pass the constant (dll path) according to the version of windows 64 or 32. I tried to pass a method as parameter, but it did not scroll and from what I saw the class dllimport only accepts static (or constant) argument. Anyone know how to solve it? Here is my code:
//const string DllName = "C:\EZForecourt\EZClient.dll";
public string DllName()
{
if (Environment.GetEnvironmentVariable("PROCESSOR_ARCHITECTURE") == "AMD64" || Environment.GetEnvironmentVariable("PROCESSOR_ARCHITEW6432") == "AMD64")
{
return "C:\EZForecourt\EZClient64.dll";
}
else
{
return "C:\EZForecourt\EZClient.dll";
}
}
//--------------------------------- Connection -----------------------------------------//
[DllImport(DllName, CharSet = CharSet.Unicode)]
internal static extern Int32 ClientLogon(Int32 ClientID, Int16 ClientType, Int32 EventHandle, System.IntPtr hWnd, Int32 wMsg);