Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
M

Member_14817640

@Member_14817640
About
Posts
1
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Use DLL in C#
    M Member_14817640

    Hello,

    I have a dll created with delphi language (Borland Delphi 7) which thus contains functions in delphi which I would like to use in C# under Visual Studio 2017. It is a native dll.
    I want to use for example the GENERATE_FILE function contained in test.dll.

    Delphi code :
    procedure GENERATE _FILE(Path, Input_File : AnsiString); stdcall;

    procedure GENERATE _FILE(Path, Input_File : AnsiString); stdcall;
    var

    begin
    …
    GENERATE_CALC(Path_And_File, CRC32, Total, err);
    …
    end;

    In C#, I want to use the function GENERATE_FILE contained in test.dll but what is the type of the parameters Path and Input_File in C# ?

    Below is an example of C# code I made to use test.dll in delphi in C#. I set string as a type for parameters of the function GENERATE_FILE.

    namespace AppTest
    {
    Public class Program
    {
    [DllImport("test.dll", CharSet = CharSet.Ansi)]
    public static extern bool CREATE_FILE(string pathDirectory, string filename);

        static void Main(string\[\] args)
        {
            GENERATE\_FILE(@"C:\\Users", "file.txt");
        }
    }
    

    }

    I added the test.dll in Visual Studio by right clicking on the project then add an existing element, then, in the properties of the test.dll, I put "Content" in Generation action and I put "Always copy "(output directory). When I run the solution, I have the test.dll in bin\Debug.

    But when I test this program, I get the following error at the line that contains:
    GENERATE_FILE(@"C:\Users", "file.txt");

    System.DllNotFoundException: 'Unable to load DLL' test.dll ': The specified module could not be found. (Exception from HRESULT: 0x8007007E) '

    How to solve this problem ?
    I think the issue is about the type of parameters in the function GENERATE_FILE. What are the type equivalents between delphi and C# for the function GENERATE_FILE ?

    Thank you for your help.

    C# help csharp delphi tutorial question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups