Hello ALL,
I 'm currently having problems dealing with passing a 'time_t' variable back and forth between a C and a C# apps.
My two apps communicate back and forth quite well with passing char and int variables. I have already built a Windows
DLL file with a lot of C functions, which the C# App calls. The communications between the C# APP and the windows dll
Api's are going quite well.
1) I want to pass back to C# from a DLL "C" routine, having a referenced time_t parameter holding a computed time
value. A current C# function call looks like this,
[DllImport("mylibrary.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern int GETEPOCHNUMBERFROMDATE(StringBuilder inpdate, ref long lreturnnumber, ref int iostatx);
The receiving "C" function declaration is as follows:
GETEPOCHNUMBERFROMDATE(char * datevar, time_t * time_tvalue, int * errstatval) {
I have to replace the C#'s call's 2nd parameter to "what" to match the "C" functions 2nd parameter; so that they
are the same data type, size, and etc; so that they can pass back and forth data seemlessly and flawlessly.
----------------
2) Using the same Function Declaration in the above mentioned call for a different problem. The 2nd parameter of the sending "C"
parameter declaration, is given a return value of -2, and the C# calling function, returns with the 2nd parameter having a 9 digit number.
It's not the -2 that it was given to be sent back. What am I doing wrong?
I'm looking for some solid, visible examples, for both these two problems, so I can see what I've done wrong, so I can mend my
ways and so I can get my two apps working properly again. So what other pieces of information have I missed, that is needed.
Thanks again for any help, in solving these two problem.
TT, May 26, 2023.
This is not a school(of any kind) assignment.
What I have tried:
What have I tried?? C/C++ and C# Code examples, MS Documentation, and from past work experiences. And have searched the internet for answers to questions. Used google looking for answers.