Jump to content
GSForum - Segélyvonal

C++ DLL C#-ba


zidan

Recommended Posts

zidan

Volna egy problémám. Van 1 C++ ban írt DLL -em.

Az alábbi:

 

#include <stdio.h>

 

#pragma once

 

using namespace System;

 

namespace ijoe {

 

public ref class Class1

{

// TODO: Add your methods for this class here.

void kiirat(){

printf("Ijoe World!");

}

int szam(){

int i=5;

return i;

}

};

}

 

Meg szeretném hívni bármelyik metóust, de sajnos nem sikerül. Hogy kellne akár mindkettõt meghívni.

 

Az alábbi C# kódom van:

 

using System;

using System.Collections.Generic;

using System.Text;

using System.Windows.Forms;

using ijoe;

using System.Runtime.InteropServices;

 

namespace ConsoleApplication1

{

class Program

{

[DllImport("ijoe.dll")]

public static extern int szam();

[DllImport("ijoe.dll")]

public static extern void kiirat();

 

static void Main(string[] args)

{

 

 

int i=szam();

System.Console.WriteLine(i);

 

 

 

 

}

}

}

 

Segítséget elõre is köszi.

 

Zidan

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...