how to use the dll developed in VC6
-
Hi, everyone I have a dll file developed by someone else in VC6. Now I tried to use it in VS.Net, but how can I do that? Thanks in advance.
If it is a COM dll, you can just use Add Reference meny by right click on your references in your project solution and select its dll in COM tab and simply use its namespace. If its not COM and its just like win32 dlls you can use DllImport to use its functions. See MSDN and this site for samples. Mazy "Man is different from animals in that he speculates, a high risk activity." - Edward Hoagland
-
If it is a COM dll, you can just use Add Reference meny by right click on your references in your project solution and select its dll in COM tab and simply use its namespace. If its not COM and its just like win32 dlls you can use DllImport to use its functions. See MSDN and this site for samples. Mazy "Man is different from animals in that he speculates, a high risk activity." - Edward Hoagland
It's not a com dll. Because when I am using "add reference", it doesn't work. Then I tried to use DllImport like this:
[System.Runtime.InteropServices.DllImport(@"C:\Visual Studio Projects\test\bin\Debug\dcli.dll", EntryPoint="AdminLogin")] public static extern bool AdminLogin(string lpctstrUser, string lpctstrPassWord);
Then I got a "DllNotFound" exception. But I already put the dll file in "C:\Visual Studio Projects\test\bin\Debug\dcli.dll". Do you know why? Thanks in advance. -
It's not a com dll. Because when I am using "add reference", it doesn't work. Then I tried to use DllImport like this:
[System.Runtime.InteropServices.DllImport(@"C:\Visual Studio Projects\test\bin\Debug\dcli.dll", EntryPoint="AdminLogin")] public static extern bool AdminLogin(string lpctstrUser, string lpctstrPassWord);
Then I got a "DllNotFound" exception. But I already put the dll file in "C:\Visual Studio Projects\test\bin\Debug\dcli.dll". Do you know why? Thanks in advance.Ugh. I think I remember reading/hearing something about this. I'm not sure I remember exactly, but I don't believe you can explicitly provide a path as you have. I think it looks for "filename.dll" in a set order of pathnames. Jeremy Kimball
-
Ugh. I think I remember reading/hearing something about this. I'm not sure I remember exactly, but I don't believe you can explicitly provide a path as you have. I think it looks for "filename.dll" in a set order of pathnames. Jeremy Kimball
Seems that your dll is delivering strings. If you want to get a string from a dll, you should use a string builder. Try something like this: StringBuilder sb = new StringBuilder( 256 ); [DllImport( "myDll.dll" )] public static extern void GetString( StringBuilder sb ); void myFunc() { GetString( sb ); Debug.WriteLine( "String = " + sb.ToString() ); }