 |
|
tumanovalex |
30-06-2015 15:28 2524292 |
Возможно ли в программе C# использовать переменную в DLL?
В программе:
Код:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
namespace CsCons
{
public class clDll
{
[DllImport("d:\\MyProgramming\\CsCpp\\Debug\\CsCppDll.dll", EntryPoint="Add", SetLastError = true, CharSet = CharSet.Auto)]
public static extern int Add(int a1);
[DllImport("d:\\MyProgramming\\CsCpp\\Debug\\CsCppDll.dll", EntryPoint = "Sub", SetLastError = true, CharSet = CharSet.Auto)]
public static extern int Sub(int s1);
}
class Program
{
static void Main(string[] args)
{
int res = clDll.Add(25);
Console.WriteLine("Результат = {0}", res);
res = clDll.Sub(15);
Console.WriteLine("Результат = {0}", res);
Console.ReadKey();
}
}
}using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
namespace CsCons
{
public class clDll
{
[DllImport("d:\\MyProgramming\\CsCpp\\Debug\\CsCppDll.dll", EntryPoint="Add", SetLastError = true, CharSet = CharSet.Auto)]
public static extern int Add(int a1);
[DllImport("d:\\MyProgramming\\CsCpp\\Debug\\CsCppDll.dll", EntryPoint = "Sub", SetLastError = true, CharSet = CharSet.Auto)]
public static extern int Sub(int s1);
}
class Program
{
static void Main(string[] args)
{
int res = clDll.Add(25);
Console.WriteLine("Результат = {0}", res);
res = clDll.Sub(15);
Console.WriteLine("Результат = {0}", res);
Console.ReadKey();
}
}
}
функции вызываются из DLL на C++. Можно ли обратиться в C# к переменной, определенной в DLL? В моем случае это Ncount. Я попробовал обратиться к ней аналогично функции, не получилось. Проект прилагаю.
|
greg zakharov |
30-06-2015 17:28 2524325 |
Как на счет чтения официальной спецификации C# или трудов Рихтера?
|
tumanovalex |
01-07-2015 12:10 2524565 |
Так обычно отвечают, когда не знают ответ.
|
Время: 21:37.
© OSzone.net 2001-