Do more with
// c_dll.cpp : Defines the exported functions for the DLL application.
//
#include "stdafx.h"
#include <stdio.h>
#include "windows.h"
__declspec(dllexport) BOOL MyGetData(char* pszName, int *pnAge, char *pszAddress,
long *pIDOB, float *pfSal, double *pdSal,
UINT * puPhone, char *byte, BOOL pbVal) {
printf("pszName = %s \n"
"pnAge = %d\n"
"pszAddress = %x\n"
"long pIdoB = %d", pszName, *pnAge, pszAddress,
*pIDOB);
*pIDOB = 100;
return TRUE;
}
This is the C side I just ignore a few parameter....
This is the C# side
using System;
using System.Runtime.InteropServices;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace EE_Examples
{
class Program
{
[DllImport("h:\\programming\\EE_Examples\\Debug\\c_dll.dll")]
static extern bool MyGetData(String pszName, out long pnAge,
Byte address, out long pIODB,
out float pfSal, out double pdSal,
out uint puPhone,
Byte anotherAddress, bool flag);
static void Main(string[] args)
{
int i = 10;
string pszName = "some name";
long pnAge = 0;
Byte foo = 0;
float floatVal;
double dVal;
Byte dummy = 0;
long pIODB;
uint puPhone = 0;
bool b_rval;
b_rval = MyGetData(pszName, out pnAge, foo, out pIODB,
out floatVal, out dVal, out puPhone, dummy, true);
Console.WriteLine("pioDB is now {0}", pIODB);
}
}
}
Premium Content
You need an Expert Office subscription to comment.Start Free Trial