-
May 27th, 2004, 09:17 AM
#1
How to declare the function?
I have this function exported by a DLL written in C.
Code:
PvcsGetRevisionInfo2(
ARCHIVEHANDLE hArchive, /* Input */
unsigned char * fileName, /* Input */
unsigned char * revision, /* Input */
unsigned char ** author, /* Output */
unsigned char ** versions, /* Output */
unsigned char ** promoGroups, /* Output */
unsigned char ** lockers, /* Output */
unsigned char ** descr, /* Output */
unsigned char * resultBuf, /* Input */
unsigned bufLen, /* Input */
void * reserved) /* Reserved */
Now, I want to be able to use this function in my code, but i can't seem to be able to declare it right.
Below is how the function prototype is currently looking:
Code:
[DllImport("Vmwfdtk.dll", CallingConvention=CallingConvention.Cdecl)]
public static extern int PvcsGetRevisionInfo2(int hArchive,
string fileName, /* Input */
string revision, /* Input */
StringBuilder author, /* Output */
StringBuilder versions, /* Output */
StringBuilder promoGroups, /* Output */
StringBuilder lockers, /* Output */
StringBuilder descr, /* Output */
StringBuilder resultBuf, /* Input */
int bufLen, /* Input */
string reserved /* Reserved */
);
If i call the function above i have nothing in author, versions, promoGroups, lockers, descr.
Can you help?thanks
-
May 27th, 2004, 02:35 PM
#2
i can't believe that i'm the only one that has tried this...really noone can help?!
-
May 28th, 2004, 01:31 AM
#3
I know I'm in the wrong forum, but i really need it bad...so please bear me
I posted this yesterday in C Sharp forum, but it seems that no one was able to respond. Can you help?
I have this function exported by a DLL written in C.
Code:
PvcsGetRevisionInfo2(
ARCHIVEHANDLE hArchive, /* Input */
unsigned char * fileName, /* Input */
unsigned char * revision, /* Input */
unsigned char ** author, /* Output */
unsigned char ** versions, /* Output */
unsigned char ** promoGroups, /* Output */
unsigned char ** lockers, /* Output */
unsigned char ** descr, /* Output */
unsigned char * resultBuf, /* Input */
unsigned bufLen, /* Input */
void * reserved) /* Reserved */
Now, I want to be able to use this function in my C Sharp code, but i can't seem to be able to declare it right.
Below is how the function prototype is currently looking:
Code:
[DllImport("Vmwfdtk.dll", CallingConvention=CallingConvention.Cdecl)]
public static extern int PvcsGetRevisionInfo2(int hArchive,
string fileName, /* Input */
string revision, /* Input */
StringBuilder author, /* Output */
StringBuilder versions, /* Output */
StringBuilder promoGroups, /* Output */
StringBuilder lockers, /* Output */
StringBuilder descr, /* Output */
StringBuilder resultBuf, /* Input */
int bufLen, /* Input */
string reserved /* Reserved */
);
If i call the function above i have nothing in author, versions, promoGroups, lockers, descr.
-
May 28th, 2004, 01:49 AM
#4
First of all declare your function (in C) with __stdcall declaration. Secondly, not all data types can be imported this way - i am not sure about this thing but try using char* instead of unsigned char*.
Hint: Do some tricks with simple functions like int arguments and returns and then move forward...
-
May 28th, 2004, 02:05 AM
#5
i think instead of string builder, you should opt for "ref string", give it a try.
If you think you CAN, you can, If you think you CAN'T, you are probably right.
Have some nice Idea to share? Write an Article Online or Email to us and You may WIN a Technical Book from CG.
-
May 28th, 2004, 02:06 AM
#6
the function is declared like this:
Code:
PVCS_APIENTRY PvcsGetRevisionInfo2(
ARCHIVEHANDLE logHandle, /* I: Archive handle */
PVCS_PUCHAR fileName, /* I: Name of logfile or workfile */
PVCS_PUCHAR revision, /* I: Revision to retrieve */
PVCS_PUCHAR *author, /* O: Userid that created revision */
PVCS_PUCHAR *versions, /* O: Version labels assigned to revision */
PVCS_PUCHAR *promoGroups, /* O: Promotion groups assigned to revision */
PVCS_PUCHAR *lockers, /* O: Userids that own a lock on revision */
PVCS_PUCHAR *descr, /* O: Change description for revision */
PVCS_PUCHAR resultBuf, /* I: Buffer to contain results */
unsigned bufLen, /* I: Length of buffer */
void *reserved);
where:
Code:
#ifndef PVCS_APIENTRY
#define PVCS_APIENTRY __declspec(dllexport) int
#endif
#ifndef PVCS_PUCHAR
#define PVCS_PUCHAR char *
#endif
The second thing is that after the function call I have a good data for 1 dimension array PVCS_PUCHAR resultBuf, for example, but not for 2 dimensions array PVCS_PUCHAR *promoGroups...
Last edited by Alin; May 28th, 2004 at 02:13 AM.
-
May 28th, 2004, 02:09 AM
#7
Sorry guy.. I have no idea...
-
May 28th, 2004, 02:14 AM
#8
nevermind, thanks anyway.
-
May 28th, 2004, 03:06 AM
#9
If Andy's suggestion doesn't work, try this. Don't know if it will work however. But it seems to me when you set an object as "out" it will need to give a pointer to the object pointer to the requested function.
Code:
[DllImport("Vmwfdtk.dll", CallingConvention=CallingConvention.Cdecl)]
public static extern int PvcsGetRevisionInfo2(int hArchive,
[in] string fileName, /* Input */
[in] string revision, /* Input */
[out] string author, /* Output */
[out] string versions, /* Output */
[out] string promoGroups, /* Output */
[out] string lockers, /* Output */
[out] string descr, /* Output */
[in] string resultBuf, /* Input */
int bufLen, /* Input */
string reserved /* Reserved */
);
Last edited by Viperius; May 28th, 2004 at 04:03 AM.
-
May 28th, 2004, 03:54 AM
#10
[moved & Merged]
Alin, keep patience. guru's dont sit here all the time. in a day or two, you will get the answer.
look at the answers in the C# forum, may be they would help you.
If you think you CAN, you can, If you think you CAN'T, you are probably right.
Have some nice Idea to share? Write an Article Online or Email to us and You may WIN a Technical Book from CG.
-
May 28th, 2004, 05:16 AM
#11
already (yesterday) tried both [out] and [ref]. no luck .
As I said, if i have a char *ch1Dim, then it's fine if I use StringBuilder, but if I have char **ch2Dim it doesn't return anything in the StringBuilder, neither it does in string, nor in char [], or string [].
should i try something like:
Code:
[MarshalAs(UnmanagedType.LPArray)] String [] ar
[MarshalAs(UnmanagedType.LPArray, ArraySubType= UnmanagedType.LPStr)] String [] ar
thanks
-
May 28th, 2004, 05:42 AM
#12
look at the answers in the C# forum, may be they would help you.
already did. there's nothing about 2 dimensions arrays that helps.
-
May 28th, 2004, 09:12 AM
#13
try StringCollection class.
If you think you CAN, you can, If you think you CAN'T, you are probably right.
Have some nice Idea to share? Write an Article Online or Email to us and You may WIN a Technical Book from CG.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|