User Profile
Collapse
-
It is not related to support optional parameters by C#. As I said you need to remove parameter from imported signature and C++ library will fill it with optional parameter itself. -
You just remove optional argument from signature in your .NET code.
Code:[DllImport("TestDriver.dll", CallingConvention = CallingConvention.StdCall, EntryPoint = "?DrfIsoMultiTagIdentify@@YGFKPAIPAUTagIds@@E@Z")] static extern short DrfIsoMultiTagIdentify(uint hCom, ref int Count, ref TagIds value);
Leave a comment:
-
Decimal 41 is hex 29. Console.WriteLi ne print all numbers as decimalLeave a comment:
-
-
I created that DLL because I don't have real dll and equipment that it uses. It just have the same convention as your DLL. You don't need to create it. I needed to check my C# code somehow.
Yes you need to put DrfApiV10.dll in place of TestDriver.dll in my example.
Whitin my C++ implementation I'm returning 0 as a result of function, assigning 1 to Count, assigning 2 to the AntNum field of tag, assigning 3 to the TagType...Leave a comment:
-
I created library with the same function exposed as your RFID driver. Then I called that function from .NET.
Header that I created:
Code:typedef struct { unsigned char TagType; unsigned char AntNum; unsigned char Ids[12]; }TagIds; typedef unsigned long HANDLE; typedef short apiStatus; apiStatus __declspec(dllexport) __stdcall DrfIsoMultiTagIdentify(HANDLE
Leave a comment:
-
Can you post C header for the function that you are trying to call?Leave a comment:
-
You posted question in C# thread.
Here is C# implementation of your three steps.
Code:byte[] byteArray = { 0xF0, 0x00, 0x67, 0x7C, 0xF1, 0x0F }; //Variable with result of your calculation. int result = 0; //Step1: Add byte values. foreach (byte value in byteArray) { result += value;
Leave a comment:
-
You can. But you said that your C and C# are separate applications. By loading DLL of another application in your C application you will execute a copy of that DLL. It will not affect other already started application with the same DLL.
DLL is just a list of commands for processor. You can load and execute it within any number of application. Each time it will be loaded in particular process memory and all variables will be saved in that...Leave a comment:
-
I'm sorry to tell it to you. You cannot read memory from other program. This dead end. This function of CPU and OS to isolate process memory.
If you need to exchange data then you need to utilize some other approach than direct memory access.
Did I answered you question?Leave a comment:
-
-
Please let us know if you really have two separate programs that have to communicate with each other. Or is it some other case? Do you need to load C library into C# program and work with it from C#?Leave a comment:
-
If you are running two different programs then you cannot access memory of one program from another. This is basic protection mechanism of OS. One program does not have access to the memory of other program, whatever you do. In addition each program has its own address space. It means that some address can point to two different values in the memory in two different programs. Thus, an address of variable in one process points to absolutely different...Leave a comment:
-
If void Set(char x) is C# then it does not have a constant address in the memory. The .NET garbage collector will move it around memory and you cannot assume that it will be at one location. There is a way to lock position of the variable in the memory and get its real address using Interop functions.
Can you describe your task more clear?Leave a comment:
-
Example of what? Calling win32 library from .NET, using COM object from .NET, or using .NET object from COM?
Maybe it will be easier if you will describe what task you need to achieve. Then I can post you some piece of code.Leave a comment:
-
.NET Interop
.NET can work with native win32 applications.
If you application is implemented as a pure win32 dll then a .NET application can call its function.
If you application is a set of COM objects then they can interact more freely. .NET can create COM objects and call their methods. COM objects can create .NET objects and call their methods.
Did it help you?Leave a comment:
-
Placeholder for Optional parameters in C#
You probably work with the Interop for the MS Excel automation library.
All parameters of Workbook.SaveAs method are optional with some predefined default values. But C# does not support optional parameters. Type.Missing serves in such situation as a placeholder for a optional parameter when you call method from C#. Interop library will replace Type.Missing values with default...Leave a comment:
No activity results to display
Show More
Leave a comment: