Click here to Skip to main content
13,090,299 members (90,033 online)
Rate this:
Please Sign up or sign in to vote.
Hello guys, I need to use a C++ Dll at C#, so I figure that I need to re-write some structs and enums. I have this code at my header file in C++.

#pragma mark STRUCTURES
    typedef void* QCam_Handle;
    typedef struct _TAG_CAM_SETTINGS_ID_GUID_STRUCT_

        uint32_t f1;
        uint16_t f2;
        uint16_t f3;
        uint8_t  f4[8];
    }QCam_settings_id, *pQCam_settings_id;
    // QCam_Settings is obsolete. Use QCam_SettingsEx in conjunction with QCam_CreateCameraSettingsStruct,
    // QCam_Err QCam_InitializeCameraSettings and QCam_ReleaseCameraSettings
    typedef struct
        unsigned long size;
        unsigned long _private_data[ 64 ];
    typedef struct
        unsigned long       size;                   // Filled by the initialization routine
        QCam_settings_id    _pSettingsID;           // pointer to the camera settings ID
        unsigned long       *_private_data;         // Pointer to a camera settings array
    QCam_SettingsEx, *pQCam_SettingsEx;
    typedef struct
        unsigned long       cameraId;           // Camera ID (ex: 0 for first camera, 1 for second)
        unsigned long       cameraType;         // Camera Model
        unsigned long       uniqueId;           // Unique ID for the camera
        unsigned long       isOpen;             // 1 if already open, 0 if closed
        unsigned long       _reserved[ 10 ];

Is there any way to do that? I'm starting at this, some help would be wonderful
Posted 18-Mar-13 0:45am
CHill60 18-Mar-13 7:26am
It's not clear what you are trying to do ... are you trying to rewrite the C++ code in C# or are you trying to call a C++ dll from C#
GustavoUgioni 18-Mar-13 8:14am
I'm trying to call a C++ dll from C#, but that dll has some methods that the return type are from typedef enum, such as:

* QCam_ListCameras()
* Discussion:
* Retrieve a list of connected cameras.
* Parameters:
* (IN) pList - User allocated array to fill in
* (OUT) pList - Filled in with the list of connected cameras
* (IN) pNumberInList - Length of the array
* (OUT) pNumberInList - Number of cameras found
* Remarks:
* On return, pNumberInList may contain a number that is bigger than the array size.
* Result:
* QCam_Err code
extern QCam_Err QCAMAPI QCam_ListCameras
QCam_CamListItem* pList,
unsigned long* pNumberInList

Where QCam_Err is:

typedef enum
qerrSuccess = 0,
qerrNotSupported = 1,
qerrStreamFault = 30, // Stream allocation failed, there may not be enough bandwidth
qerrQCamUpdateNeeded = 31, // QCam needs to be updated
qerrRoiTooSmall = 32, // The ROI used is too small
qerr_last = 33,
_qerr_force32 = 0xFFFFFFFF

And there are also some methods that the return type are structs.

I thought I should rewrite some parts of the header file in C#, or is that a cleaver way to do that?

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04 | 2.8.170813.1 | Last Updated 18 Mar 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100