Skip to content

Calling unmanaged dlls dynamically in C#.NET

sarada

Asked Oct 22, 2008, 3:33 AM EDT2 answers
Share
LinkedInX
Actually I have an application(dll) written in VC++. That dll I want to call in C#.NET dynamically.. Can anybody help on this....ASAP.. Thanks, Saru

2 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    To call unmanaged code you'd use platform invoke. If, for isntance, you wanted to call the function int puts(string) from mscvrt.dll you'd first declare this as:
    C#
    [DllImport("msvcrt.dll")]
    public static extern int puts(string c);
    
    Then you can call the function.
    
    Check out:
    Platform Invoke Tutorial
    
    Regards,
    Daniel
    0
  • 0
    To call unmanaged code you'd use platform invoke. If, for isntance, you wanted to call the function int puts(string) from mscvrt.dll you'd first declare this as:
    C#
    [DllImport("msvcrt.dll")]
    public static extern int puts(string c);
    
    Then you can call the function.
    
    Check out:
    Platform Invoke Tutorial
    
    Regards,
    Daniel
    0