C function syntax is
PvcsGetRevision Info2(
HANDLE 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)
Please can you help to convert this syntax to C#. 6 3364
void PvcsGetRevision Info2(
ref int hArchive,
string filename,
string revision,
ref string author,
ref string versions,
ref string promoGroups,
ref string lockers,
ref string descr,
string resultbuf,
int bufLen,
IntPtr reserved);
I think ...
Thanks but are you sure about
the 'unsigned char **' converts to 'ref string'.
char* is string ... A safe assumption would be that char ** is a
reference to a string ...
I forgot to state the following about the parameters
versions (Output). Pointer to a pointer to a list of
strings. Each is a version label associated with
this revision. If Developer's Toolkit returns a
null pointer, then no version labels are
present.
promoGroups (Output). Pointer to a pointer to a list of
strings. Each string is a promotion group
associated with this revision. The strings are
null-separated with a double-null pointer at
the end of the list. Developer's Toolkit returns
a null pointer if no promotion groups are
present.
lockers (Output). Pointer to a pointer to a list of
strings. Each is a user ID that owns a lock on
the revision. The strings for these are nullseparated
with a double-null pointer at the
end of the list. Developer's Toolkit returns a
null pointer if no locks are present.
descr (Output). Pointer to a pointer to a string: the
revision change description. If Developer's
Toolkit returns a null pointer, then no change
description is present.
resultBuf Pointer to a buffer that this function uses to
store the result data. Your program must
allocate the buffer. The pointers referenced
by author, versions, promoGroups, lockers, and
description will point to memory in resultBuffer.
bufLen Length of the result buffer.
reserved Reserved for future use. Must be null.
You have a bigger problem in that 'C' strings do not map directly to C#
strings. A 'C' is a set of characters terminated by the null (0x00)
character. Where as a C# string has an associated length but is not
terminated by a null character (nulls are legal characters in C# strings).
The normal method of string transfer between C# and 'C' or 'C++' is to use
marshalling. Arrays are another area where 'C' or 'C++' and C# differ.
Because of the dynamic memory characteristics of C# marshalling again is
important. Given a little more time, I can dig up an example for you if you
can not resolve the issue.
Pat
"BuddyWork" wrote: I forgot to state the following about the parameters
versions (Output). Pointer to a pointer to a list of strings. Each is a version label associated with this revision. If Developer's Toolkit returns a null pointer, then no version labels are present.
promoGroups (Output). Pointer to a pointer to a list of strings. Each string is a promotion group associated with this revision. The strings are null-separated with a double-null pointer at the end of the list. Developer's Toolkit returns a null pointer if no promotion groups are present.
lockers (Output). Pointer to a pointer to a list of strings. Each is a user ID that owns a lock on the revision. The strings for these are nullseparated with a double-null pointer at the end of the list. Developer's Toolkit returns a null pointer if no locks are present.
descr (Output). Pointer to a pointer to a string: the revision change description. If Developer's Toolkit returns a null pointer, then no change description is present.
resultBuf Pointer to a buffer that this function uses to store the result data. Your program must allocate the buffer. The pointers referenced by author, versions, promoGroups, lockers, and description will point to memory in resultBuffer.
bufLen Length of the result buffer.
reserved Reserved for future use. Must be null.
Thanks for the reply,
I've think I've sovled the problem, I need to do more testing
Here is the converted C to C# function
[DllImport("VMWF DTK.DLL")]
public static extern PVCS_E PvcsGetRevision Info2(
IntPtr logHandle, /* I: Archive handle */
string fileName, /* I: Name of logfile or workfile */
string revision, /* I: Revision to retrieve */
ref string author, /* O: Userid that created revision */
ref IntPtr versions, /* O: Version labels assigned to revision */
ref IntPtr promoGroups, /* O: Promotion groups assigned to revision
*/
ref IntPtr lockers, /* O: Userids that own a lock on revision */
ref string descr, /* O: Change description for revision */
IntPtr resultBuf, /* I: Buffer to contain results */
int bufLen, /* I: Length of buffer */
IntPtr reserved); /* Reserved for future use */
For the parameters that are pointer to a pointer I've used the Marshal
object to loop through and retrieve the string by checking for the null
pointer. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Eric Hendriks |
last post by:
// In an unmanaged DLL the following function must be called:
// int VFGeneralize(const BYTE * const * features);
// "features" parameter is supposed to be an array of byte arrays.
// function is Marshaled as follows:
static extern int VFGeneralize(byte features);
In C# I have the following:
// Allocate memory to store "Count" references to byte arrays
|
by: Timothy Shih |
last post by:
Hi, I am trying to figure out how to use unmanaged code using P/Invoke. I
wrote a simple function which takes in 2 buffers (one a byte buffer, one a
char buffer) and copies the contents of the byte buffer into the character
pointer. The code looks like the following:
#include <stdio.h>
#include <stdlib.h>
#include "stdafx.h"
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
|
by: Stefan |
last post by:
I have the following question
The Marshal class contains a function to allocate a block of memory
1. Marshal.AllocHGlobal ( int cb
2. Marshal.AllocHGlobal ( IntPtr cb
The first version I can understand, because the integer indicates the size of the memory block that is required
But the second version I do not understand. If I want a memoryblock of 20 bytes could I use
IntPtr p = Marshal.AllocHGlobal ( new IntPtr ( 20 ) )
|
by: kevin |
last post by:
Hi
I have a C struct that is of the following
typedef struct{
DWORD num_conversions; ...
short *sample_values;
....
|
by: SQACSharp |
last post by:
I'm trying to get the control name of an editbox in another window.
The following code set the value "MyPassword" in the password EditBox
but it fail to return the control name of the EditBox. I'm sure the
problem is the way i'm using the sendmessage API, the return string and
the lParam return 0....is anybody have a clue? any sendmessage api
expert here?
public static extern Int32 FindWindow(String lpClassName,String
| |
by: nicewenyan |
last post by:
I want to pass a managed c# byte (8 bit) array into a unmanaged c++
function:
extern "C" void AddData(unsigned int* data);
I use P/Invoke on managed side to do the marshaling as following:
public static extern int AddData(IntPtr data);
|
by: Javad |
last post by:
Hello
I know that I should get the information of windows internet connections by
using "rasapi32.dll" library, and I also have some sample codes, but I can't
make them work. My exact need is to get the "UserName" of a connection. How
is it possible?
plz hlp
thnk u
|
by: =?Utf-8?B?UmF2aSBTaGFua2Fy?= |
last post by:
Hi,
I have a requirement where I need to call methods written in VB.Net from a
C++ code. I have been going crazy reading various articles on the net w.r.t
interop and marshalling but an more confused now that before.
the signature I need to conform in the VB.Net DLL is
int MyAppInitFunc(int argc, char** argv)
To this extent I have tried the following
|
by: =?Utf-8?B?UHVjY2E=?= |
last post by:
Hi, I'm using vs2005, .net 2, C# for Windows application. I use DllImport so
I can call up a function written in C++ as unmanaged code and compiled as a
dll us vs2005. My application is able to call the function, EncodeAsnUser.
And it's returning OK but when I display the decoded data in another part of
my application it shows no data has been decoded, all fiedls are either null
or blanks. For some reason, I am not able to step through...
|
by: David Hirschfield |
last post by:
I had a situation recently that required I manually load python bytecode
from a .pyc file on disk.
So, for the most part, I took code from imputil.py which loads the .pyc
data via the marshal module and then exec's it into a newly created
module object (created by imp.new_module()). The relevant pieces of code
are in imputil.py_suffix_importer and imputil.Importer._process_result
(where it exec's the code into the module's __dict__)
...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |