function pointer

  • Thread starter Thread starter Lance Johnson
  • Start date Start date
L

Lance Johnson

I'm using an external DLL that expects the address of a function for a
callback. How can I go about getting the address of a function I have?
Thanks for any help in this.

Lance Johnson
 
you have to declare delegate

public delegate void TestCallback();

and pass it as a parameter to the function in DllImport.

[DllImport("Sample.dll")]
public static extern void SomeFunction(TestCallback callback);
 
Thanks for the reply. I believe this assumes it's just a regular function.
However, the function in the external DLL is a member function. Is there
anything special I have to do for that to work because I'm not just calling
a particular function but instead a function on an instance of some class.

Lance Johnson


Shakir Hussain said:
you have to declare delegate

public delegate void TestCallback();

and pass it as a parameter to the function in DllImport.

[DllImport("Sample.dll")]
public static extern void SomeFunction(TestCallback callback);

--
Shak
(Houston)


Lance Johnson said:
I'm using an external DLL that expects the address of a function for a
callback. How can I go about getting the address of a function I have?
Thanks for any help in this.

Lance Johnson
 
When you pass structures or callbacks to Api's using DllImport, you have to
create a Managed code by duplicating the structure or function in c#. You
have to use those to the function to handle things. Refer MSDN hpw to do
that.

--
Shak
(Houston)


Lance Johnson said:
Thanks for the reply. I believe this assumes it's just a regular function.
However, the function in the external DLL is a member function. Is there
anything special I have to do for that to work because I'm not just calling
a particular function but instead a function on an instance of some class.

Lance Johnson


Shakir Hussain said:
you have to declare delegate

public delegate void TestCallback();

and pass it as a parameter to the function in DllImport.

[DllImport("Sample.dll")]
public static extern void SomeFunction(TestCallback callback);

--
Shak
(Houston)


Lance Johnson said:
I'm using an external DLL that expects the address of a function for a
callback. How can I go about getting the address of a function I have?
Thanks for any help in this.

Lance Johnson
 
I don't know what you mean by hpw and when I do a search for hpw it returns
nothing.

Lance Johnson

Shakir Hussain said:
When you pass structures or callbacks to Api's using DllImport, you have to
create a Managed code by duplicating the structure or function in c#. You
have to use those to the function to handle things. Refer MSDN hpw to do
that.

--
Shak
(Houston)


Lance Johnson said:
Thanks for the reply. I believe this assumes it's just a regular function.
However, the function in the external DLL is a member function. Is there
anything special I have to do for that to work because I'm not just calling
a particular function but instead a function on an instance of some class.

Lance Johnson


Shakir Hussain said:
you have to declare delegate

public delegate void TestCallback();

and pass it as a parameter to the function in DllImport.

[DllImport("Sample.dll")]
public static extern void SomeFunction(TestCallback callback);

--
Shak
(Houston)


I'm using an external DLL that expects the address of a function for a
callback. How can I go about getting the address of a function I have?
Thanks for any help in this.

Lance Johnson
 
Sorry,

it was a typo, i meant

Refer MSDN how to do that

--
Shak
(Houston)


Lance Johnson said:
I don't know what you mean by hpw and when I do a search for hpw it returns
nothing.

Lance Johnson

Shakir Hussain said:
When you pass structures or callbacks to Api's using DllImport, you have to
create a Managed code by duplicating the structure or function in c#. You
have to use those to the function to handle things. Refer MSDN hpw to do
that.

--
Shak
(Houston)


Lance Johnson said:
Thanks for the reply. I believe this assumes it's just a regular function.
However, the function in the external DLL is a member function. Is there
anything special I have to do for that to work because I'm not just calling
a particular function but instead a function on an instance of some class.

Lance Johnson


you have to declare delegate

public delegate void TestCallback();

and pass it as a parameter to the function in DllImport.

[DllImport("Sample.dll")]
public static extern void SomeFunction(TestCallback callback);

--
Shak
(Houston)


I'm using an external DLL that expects the address of a function
for
 
If your "function" is a method of a native C++ class in an external DLL,
then you can't call it directly.
One possible option is to create a managed wrapper class using VS2003's
Managed Extentions for C++ and populate the class with thunk methods that
invoke the associated native method(s).

Willy.


Lance Johnson said:
Thanks for the reply. I believe this assumes it's just a regular
function.
However, the function in the external DLL is a member function. Is there
anything special I have to do for that to work because I'm not just
calling
a particular function but instead a function on an instance of some class.

Lance Johnson


Shakir Hussain said:
you have to declare delegate

public delegate void TestCallback();

and pass it as a parameter to the function in DllImport.

[DllImport("Sample.dll")]
public static extern void SomeFunction(TestCallback callback);

--
Shak
(Houston)


Lance Johnson said:
I'm using an external DLL that expects the address of a function for a
callback. How can I go about getting the address of a function I have?
Thanks for any help in this.

Lance Johnson
 
Back
Top