zidan Posted November 25, 2007 Posted November 25, 2007 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
artur02 Posted November 26, 2007 Posted November 26, 2007 Ehhez Platform Invoke-ra van szükséged. Gyakorlatilag ez egy DllImport attribútumot jelent. Az alábbi linkrõl el tudsz indulni: http://msdn2.microsoft.com/en-us/library/s...tattribute.aspx
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now