Re: Calling dll functions

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance




"John" <John@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:0F784C81-9ED4-425D-8ADF-89BF15762C3A@xxxxxxxxxxxxxxxx
DWORD _stdcall DLLFunction(DWORD Num, CHAR *Str);

I call the above dll function from a C++ app. Now I need to call it from my
C# app. How can I do it?

[DllImport("MyDll.dll")]
public static extern int DLLFunction(int Num, string Info);

int Num;
string Info = new string(' ', 80);
DLLFunction(Num, Info);

I cannot get anything in variable Info. Please help. Thanks.

[DllImport("myDll.dll")]
public static extern int DLLFunction(out int Num, StringBuilder Info);

int Num;
string Info = new StringBuilder(80);
DLLFunction(out Num, Info);
string results = Info.ToString();

HTH,
Mythran

.



Relevant Pages

  • Re: Calling dll functions
    ... I call the above dll function from a C++ app. ... public static extern int DLLFunction(int Num, string Info); ... public static extern int DLLFunction(out int Num, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Calling dll functions
    ... Try StringBuilder instead of string type. ... I call the above dll function from a C++ app. ... public static extern int DLLFunction ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: June 2005 EAL Question
    ... parameter to a string. ... > public class MyEventLogInstaller: Installer ... You have a web app, ... >>> at Microsoft.Win32.RegistryKey.OpenSubKey(String name, Boolean ...
    (microsoft.public.dotnet.general)
  • Re: Running other applications
    ... associated with a file type (extension). ... file and calling FindExecutable: ... ByVal lpDirectory As String, ByVal lpResult As String) As Long ... > The app is a program called Data Junction. ...
    (microsoft.public.vb.general.discussion)
  • Re: Cant register Windows Scripting Host with Windows 7
    ... My app has been in use since 1999 and is designed to work on Win 95 onwards hence the installer has always include WSH. ... One functions I have used it for in the program is to find the location of the users special folders eg. documents folder and then to delete a subfolder. ... Public Function GetSpecialFolderAs String ... Dim lNullPos As Long ...
    (microsoft.public.vb.general.discussion)