Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / November 2005

Tip: Looking for answers? Try searching our database.

Dll parameter:  pointer to a unsigned char[] as parameter

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Patrick - 19 Nov 2005 02:46 GMT
To people wiser than myself:
 I'm calling a native dll in C# that takes a frame number and a pointer to
an unsigned char to populate with video data. Here's the C++ method
Signature:

void DirectShowSource::GetFrame(int n, unsigned char* buf)

and here is my attempt:

[DllImport("vidframe.dll", EntryPoint = "?getFrame@@YAPAEH@Z")]

private static extern void getFrameDll(int FrameNumber, ref char[] buffer);

which doesn't seem to cut it.

What is the pointer to an unsigned char for? The memory address that
containes a byte array?

If so, how do I get it? If not, could someone please offer advice or
direction?

Many thanks to this great crowd,

--Patrick
Willy Denoyette [MVP] - 19 Nov 2005 17:28 GMT
> To people wiser than myself:
>  I'm calling a native dll in C# that takes a frame number and a pointer to
[quoted text clipped - 21 lines]
>
> --Patrick

Could be wrong, but it looks like you are trying to call a C++ class member
method, which is impossible from C#. The reason why I'm saying this is that
you are seting the entry point to the mangled name, which makes me believe
that GetFrame isn't exported as a C function (using C bindings). Do you have
any API description for that library that you could consult, before you
start calling into something?

To answer you question about unsigned char*, it's simply a pointer( to a
memory location) that will be threated as pointing to an unsigned char. when
you dereference the pointer (read the contents).

Willy.


Patrick - 20 Nov 2005 05:50 GMT
Your right, it is a C++ class member method, and I don't have any
documentation for the API library (but I do have the source). I'm trying to
convert some delphi code that uses that library dll over to csharp. Here's
how delphi calls GetFrame:

function getFrameDll(frame: integer): PByteArray; cdecl; external
'vidframe.dll' name '?getFrame@@YAPAEH@Z';

It is a function. But the actual C++ source to GetFrame is this:

void DirectShowSource::GetFrame(int n, unsigned char* buf)

>> To people wiser than myself:
>>  I'm calling a native dll in C# that takes a frame number and a pointer
[quoted text clipped - 34 lines]
>
> Willy.
Willy Denoyette [MVP] - 19 Nov 2005 20:20 GMT
Well, as I said in my previous reply, C# can't call C++ member functions,
member functions are called using the 'this' pointer (a pointer to the class
instance) which you can't obtain from C# as you can't create instances of
unmaged classes from C#. Don't know how you managed this to be called from
Delphi though - are you really sure it's a member function?.
Anyway to solve your problem (without the need to change the library), is to
build a wrapper class using MC++ (VS2003) or C++/CLI (VS2005). You can check
MSDN for sample how to do this.

Willy.

> Your right, it is a C++ class member method, and I don't have any
> documentation for the API library (but I do have the source). I'm trying
[quoted text clipped - 46 lines]
>>
>> Willy.
Patrick - 22 Nov 2005 01:50 GMT
Thanks Willy :)

> Well, as I said in my previous reply, C# can't call C++ member functions,
> member functions are called using the 'this' pointer (a pointer to the
[quoted text clipped - 58 lines]
>>>
>>> Willy.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.