One of the requirements for a PDA product was to subclass a window in a dll which is created in a C# application.
GUI for the same was developed using C# and for recording functionality they have a dll created using embedded VC++. Now, the waveform-audio input device sends a notification message to the specified window, but the question was how to get a window handle which is created in C# application so that it can be passed as a parameter for waveInOpen function? We need to somehow pass the window handle to dll so that dll can subclass the window and the messages can be processed in the dll itself.
This is what I did and it seems to be working fine.
First of all the functions implemented in dll are called using dllimport in the C# application. You need to write the following code to access the functions exported from this dll (Recrdr.dll). I have put all these functions in a class named Wrapper.
public class Wrapper
{
[DllImport("Recrdr.dll", EntryPoint="StartRecording")]
static extern public bool StartRecording ();
[DllImport("Recrdr.dll", EntryPoint="StopRecording")]
static extern public bool StopRecording ();
[DllImport("Recrdr.dll", EntryPoint="StartPlaying")]
static extern public bool StartPlaying(string sFile);
[DllImport("Recrdr.dll", EntryPoint="StopPlaying")]
static extern public bool StopPlaying ();
...
...
}
I added one more function in the dll which will accept the window handle of a C# window. I imported the same in the C# application.
[DllImport("Recrdr.dll", EntryPoint="SetParentWnd")]
static extern public bool SetParentWnd(UInt32 hWnd);
Now, I need to pass the windows handle to this function (Please note that this.Handle is not supported in .Net Compact framework). Then how do we do this? Well, again we need to call a windows api for getting the window handle. For that, you need to import the windows dll named coredll.dll which implements GetForegroundWindow function.
sara brownPosted Apr 4, 2009, 1:49 AM
help me plz
Jayprakash JangirPosted Apr 1, 2009, 3:19 AM
hi this is jayprakash i am facing problem in importing dll file. i want to inport Dll which is created in Clarion (4GL) in C#.Net. i hv used this code for that ================================================================= [DllImport(@"C:\myapp.dll", EntryPoint = "SumOfTwoNumber", ExactSpelling = false, SetLastError = true)] public static extern long SumOfTwoNumber(long X,long Y); ================================================================= but still i am facing an error ================================================================= Error : Unable to find an entry point named 'SumOfTwoNumber' in DLL 'C:\myapp.dll'. ================================================================= if u can help me then plzzzzzz thankx hv a nice time