Hi,

I'm working on this project and it requires to manually control a digital camera. I have the dll that is supplied by Cannon, but the dll is unmanaged the the demo project they have with it is in C++ or C. I've been doing a lot of research and tried lots of things but I have found that I am receiving errors. I beleive the method is returning a Uint32 or ulong data type and it requires a C++ pointer. I believe this is what I have, but I left my notes at my house. I'll post more accurate code when I get home in 6 hours from now. But does anyone know how to call a pointer in C#?

cdCAPI RDKStart(cdVAR * pFunctions)
 
[Import "RDSK.DLL"]
static extern Uint32 RDKStart([out] Uint32 pFunctions)
unsafe
{
// use pointers
}

don't forget to set your project to allow unsafe blocks of code
From project properties->Build->Allow unsafe code

I'm not sure if you understand. I have a unmanged dll that I'm trying to call. The notes in C++ are

cdCAPI RDStartSDK(cdUInt32    Option);

i believe that cdCAPI is ulong type and cdUInt32 is Uint32 type. I'm using C# to write my program. This is what I have so far.

[DllImport("RDSDK.dll")]
static extern UInt32 RDStartSDK(Int32 Option);

I am getting 238765 return and the notes say that it is suppose to return zero if everything went ok.

u said "I beleive the method is returning a Uint32 or ulong data type and it requires a C++ pointer"
I told you how to use pointers in C#, ask a specific question to understand you well.

I didn't use this API before, check its documentation for further help, anything about unmanaged dll, ask and I'll help you

The documentation is for C++ and I'm programming in C#. I've had a bit of experience with C++ but that was awhile ago. The documentation doesn't tell me that much. I guess what I'm looking for is the syntax for using pointers. " /// use pointers " doesn't really help me out since I don't know how to use pointers in C#

No difference Nedwards,
Just enable your project to allow unsafe code (first reply) then in call your external method surround it by unsafe like

unsafe
{
uint* pointerOnUnsignedInteger;
}

another example if you have method retuerns a pointer on integer let's say its name "Foo" you can use it like

unsafe
{
int* p_integer = Foo();
}

Well it turns out that the whole functionallity of that is going to be dropped, because what happens when the camera breaks? We would then need a new camera and have to rewrite the software for it. So I learned lots, but I still had a long way to go.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.