C++ SDK Access from C# (Canon SDK)

Completed Posted May 24, 2006 Paid on delivery
Completed Paid on delivery

I'm trying to call a C++ function in an SDK from a C# app.

The function is defined as:

prCAPI PR_GetDeviceList(

prUInt32* pBufferSize,

prDeviceList* pDeviceList

);

where pBufferSize is a pointer to the buffer size and pDeviceList is a pointer to a prDeviceList struct.

prCAPI is an UInt32 and is 0x00 if the function is successful.

## Deliverables

The structs are defined in a header file as the following:

typedef struct{

prWChar DeviceInternalName[512]; /* Internal device name (512 characters) */

prWChar ModelName[32]; /* Camera model name (32 characters) */

prUInt16 Generation; /* Camera generation number */

prUInt32 Reserved1; /* Reserved */

prUInt32 ModelID; /* Camera model ID */

prUInt16 Reserved2; /* Reserved */

prPorttype PortType; /* Port type 0x01?FWIA / 0x02?FSTI */

prUInt32 Reserved3; /* Reserved */

}prDeviceInfoTable;

typedef struct{

prUInt32 NumList; /* Number of camera device information included in this structure */

prDeviceInfoTable DeviceInfo[prANY]; /* Camera device information. This array is variable */

}prDeviceList;

The types are defined as:

unsigned long prCAPI

unsigned ushort prWChar

usigned long prUInt32

unsigned short prUInt16

unsigned short prPorttype

prAny 1

Using InteropServices in C#, I re wrote the function and the structs:

public static extern UInt32 PR_GetDeviceList(ref UInt32 pBufferSize, out IntPtr pDeviceList);

public struct prDeviceList

{

public UInt32 NumList; /* Number of camera device information included in the struct */

public prDeviceInfoTable[] DeviceInfo; /* Camera device information */

}

[StructLayout([url removed, login to view], CharSet=[url removed, login to view])]

public struct prDeviceInfoTable

{

[MarshalAs([url removed, login to view], SizeConst=512)]

public string DeviceInternalName; /* Internal device name (512 characters) */

[MarshalAs([url removed, login to view], SizeConst = 32)]

public string ModelName; /* Camera model name (32 characters) */

public UInt16 Generation; /* Camera generation number */

public UInt32 Reserved1; /* Reserved */

public UInt32 ModelID; /* Camera model ID */

public UInt16 Reserved2; /* Reserved */

public UInt16 PortType; /* Port type 0x01?FWIA / 0x02?FSTI */

public UInt32 Reserved3; /* Reserved */

}

Can anyone tell me how i go about calling the function then retrieve the prDeviceList struct using the pointer and then enumerate the prDeviceInfoTable structs in the array [url removed, login to view]

*************

1) Complete and fully-functional working program(s) in executable form as well as complete source code of all work done.

2) Deliverables must be in ready-to-run condition, as follows (depending on the nature of the deliverables):

a) For web sites or other server-side deliverables intended to only ever exist in one place in the Buyer's environment--Deliverables must be installed by the Seller in ready-to-run condition in the Buyer's environment.

b) For all others including desktop software or software the buyer intends to distribute: A software installation package that will install the software in ready-to-run condition on the platform(s) specified in this bid request.

3) All deliverables will be considered "work made for hire" under U.S. Copyright law. Buyer will receive exclusive and complete copyrights to all work purchased. (No GPL, GNU, 3rd party components, etc. unless all copyright ramifications are explained AND AGREED TO by the buyer on the site per the coder's Seller Legal Agreement).

## Platform

C# - .Net 2.0 - Windows XP Pro

C Programming C# Programming Engineering MySQL Odd Jobs PHP Software Architecture Software Testing

Project ID: #3526385

About the project

Remote project Active May 25, 2006

Awarded to:

siarheiaksi

See private message.

$72.25 USD in 3 days
(45 Reviews)
5.7