Click here to Skip to main content
15,880,543 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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++.

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 ];
    }
    QCam_Settings;

    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 ];
    }
    QCam_CamListItem;


Is there any way to do that? I'm starting at this, some help would be wonderful
Posted
Comments
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
}
QCam_Err;

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

 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900