473,405 Members | 2,445 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Wrapping a COM DLL

hi all,

i've asked a similar question recently regarding accessing the Windows
Address Book by creating a wrapper class in C#

I need to know whether I'm barking up the wrong the tree?

What i've started doing is creating the required structs and declaring
function calls within the wab32.dll in managed code (C#) but the problem i'm
now faced with having to pass an pointer (IntPtr) to an interface as a
parameter to one of the functions.

Do i have to declare the interfaces i need as c# interfaces? or can i need
to DllImport them?

if you know what i'm talking about then you probably know i don't

any help / pointers appreciated

tia
Sam Martin
Nov 16 '05 #1
5 3672
Sam,

Which function are you trying to declare in wab32.dll? If you can give
the function (and possibly the unmanaged declaration) it would help
tremendously.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Sam Martin" <sa*********@yahoo.co.uk> wrote in message
news:Of*************@tk2msftngp13.phx.gbl...
hi all,

i've asked a similar question recently regarding accessing the Windows
Address Book by creating a wrapper class in C#

I need to know whether I'm barking up the wrong the tree?

What i've started doing is creating the required structs and declaring
function calls within the wab32.dll in managed code (C#) but the problem i'm now faced with having to pass an pointer (IntPtr) to an interface as a
parameter to one of the functions.

Do i have to declare the interfaces i need as c# interfaces? or can i need
to DllImport them?

if you know what i'm talking about then you probably know i don't

any help / pointers appreciated

tia
Sam Martin

Nov 16 '05 #2
hi nick,

thanks for reply,

it's
HRESULT WABOpen(
LPADRBOOK *lppAdrBook,
LPWABOBJECT *lppWABObject,
LPWAB_PARAM lpWABParam,
DWORD Reserved2
);

Basically i'm guessing the implementation would be something like

[DllImport("wab32.dll")]
static public extern uint WABOpen(ref IntPtr lppAdrBook, ref IntPtr
lppWABObject, ref IntPtr lpWABParam, uint Reserved2);

so you can obtain an IntPtr to an object (interface) that has a series of
methods, how do you then invoke those methods?

Thanks
Sam

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:%2****************@TK2MSFTNGP09.phx.gbl...
Sam,

Which function are you trying to declare in wab32.dll? If you can give the function (and possibly the unmanaged declaration) it would help
tremendously.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Sam Martin" <sa*********@yahoo.co.uk> wrote in message
news:Of*************@tk2msftngp13.phx.gbl...
hi all,

i've asked a similar question recently regarding accessing the Windows
Address Book by creating a wrapper class in C#

I need to know whether I'm barking up the wrong the tree?

What i've started doing is creating the required structs and declaring
function calls within the wab32.dll in managed code (C#) but the problem

i'm
now faced with having to pass an pointer (IntPtr) to an interface as a
parameter to one of the functions.

Do i have to declare the interfaces i need as c# interfaces? or can i need to DllImport them?

if you know what i'm talking about then you probably know i don't

any help / pointers appreciated

tia
Sam Martin


Nov 16 '05 #3
Sam,

You should actually define the IAddrBook interface in your code (using
the appropriate ComImport and Guid attributes as well), and then set the
return type to that. The COM interop layer will take care of it. Just make
sure that the parameter type is "ref IAddrBook".
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Sam Martin" <sa*********@yahoo.co.uk> wrote in message
news:eL**************@TK2MSFTNGP10.phx.gbl...
hi nick,

thanks for reply,

it's
HRESULT WABOpen(
LPADRBOOK *lppAdrBook,
LPWABOBJECT *lppWABObject,
LPWAB_PARAM lpWABParam,
DWORD Reserved2
);

Basically i'm guessing the implementation would be something like

[DllImport("wab32.dll")]
static public extern uint WABOpen(ref IntPtr lppAdrBook, ref IntPtr
lppWABObject, ref IntPtr lpWABParam, uint Reserved2);

so you can obtain an IntPtr to an object (interface) that has a series of
methods, how do you then invoke those methods?

Thanks
Sam

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in message news:%2****************@TK2MSFTNGP09.phx.gbl...
Sam,

Which function are you trying to declare in wab32.dll? If you can

give
the function (and possibly the unmanaged declaration) it would help
tremendously.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Sam Martin" <sa*********@yahoo.co.uk> wrote in message
news:Of*************@tk2msftngp13.phx.gbl...
hi all,

i've asked a similar question recently regarding accessing the Windows
Address Book by creating a wrapper class in C#

I need to know whether I'm barking up the wrong the tree?

What i've started doing is creating the required structs and declaring
function calls within the wab32.dll in managed code (C#) but the
problem
i'm
now faced with having to pass an pointer (IntPtr) to an interface as a
parameter to one of the functions.

Do i have to declare the interfaces i need as c# interfaces? or can i

need to DllImport them?

if you know what i'm talking about then you probably know i don't

any help / pointers appreciated

tia
Sam Martin



Nov 16 '05 #4
ok, so i think i've got it

basically define the IAddrBook interface in c# - how do you know what Com
attribs to use
I've been looking for a while now and still no good examples of how to do
this. (normally the interop classes are created by tlbimp no?)

thanks again mate

sam
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:ui**************@TK2MSFTNGP11.phx.gbl...
Sam,

You should actually define the IAddrBook interface in your code (using
the appropriate ComImport and Guid attributes as well), and then set the
return type to that. The COM interop layer will take care of it. Just make sure that the parameter type is "ref IAddrBook".
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Sam Martin" <sa*********@yahoo.co.uk> wrote in message
news:eL**************@TK2MSFTNGP10.phx.gbl...
hi nick,

thanks for reply,

it's
HRESULT WABOpen(
LPADRBOOK *lppAdrBook,
LPWABOBJECT *lppWABObject,
LPWAB_PARAM lpWABParam,
DWORD Reserved2
);

Basically i'm guessing the implementation would be something like

[DllImport("wab32.dll")]
static public extern uint WABOpen(ref IntPtr lppAdrBook, ref IntPtr
lppWABObject, ref IntPtr lpWABParam, uint Reserved2);

so you can obtain an IntPtr to an object (interface) that has a series of
methods, how do you then invoke those methods?

Thanks
Sam

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote

in
message news:%2****************@TK2MSFTNGP09.phx.gbl...
Sam,

Which function are you trying to declare in wab32.dll? If you can

give
the function (and possibly the unmanaged declaration) it would help
tremendously.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Sam Martin" <sa*********@yahoo.co.uk> wrote in message
news:Of*************@tk2msftngp13.phx.gbl...
> hi all,
>
> i've asked a similar question recently regarding accessing the Windows > Address Book by creating a wrapper class in C#
>
> I need to know whether I'm barking up the wrong the tree?
>
> What i've started doing is creating the required structs and declaring > function calls within the wab32.dll in managed code (C#) but the problem i'm
> now faced with having to pass an pointer (IntPtr) to an interface as a > parameter to one of the functions.
>
> Do i have to declare the interfaces i need as c# interfaces? or can

i need
> to DllImport them?
>
> if you know what i'm talking about then you probably know i don't
>
> any help / pointers appreciated
>
> tia
> Sam Martin
>
>



Nov 16 '05 #5
cheers nick, found an ms tutorial on ComImport

if anyone finds this thread with same problem ... look here
http://msdn.microsoft.com/library/de...ntTutorial.asp

now off to laboriously retype ms's wab api... sweet

sam

"Sam Martin" <sa*********@yahoo.co.uk> wrote in message
news:uD**************@TK2MSFTNGP09.phx.gbl...
ok, so i think i've got it

basically define the IAddrBook interface in c# - how do you know what Com
attribs to use
I've been looking for a while now and still no good examples of how to do
this. (normally the interop classes are created by tlbimp no?)

thanks again mate

sam
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in message news:ui**************@TK2MSFTNGP11.phx.gbl...
Sam,

You should actually define the IAddrBook interface in your code (using
the appropriate ComImport and Guid attributes as well), and then set the
return type to that. The COM interop layer will take care of it. Just make
sure that the parameter type is "ref IAddrBook".
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Sam Martin" <sa*********@yahoo.co.uk> wrote in message
news:eL**************@TK2MSFTNGP10.phx.gbl...
hi nick,

thanks for reply,

it's
HRESULT WABOpen(
LPADRBOOK *lppAdrBook,
LPWABOBJECT *lppWABObject,
LPWAB_PARAM lpWABParam,
DWORD Reserved2
);

Basically i'm guessing the implementation would be something like

[DllImport("wab32.dll")]
static public extern uint WABOpen(ref IntPtr lppAdrBook, ref IntPtr
lppWABObject, ref IntPtr lpWABParam, uint Reserved2);

so you can obtain an IntPtr to an object (interface) that has a series of methods, how do you then invoke those methods?

Thanks
Sam

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:%2****************@TK2MSFTNGP09.phx.gbl...
> Sam,
>
> Which function are you trying to declare in wab32.dll? If you
can give
> the function (and possibly the unmanaged declaration) it would help
> tremendously.
>
>
> --
> - Nicholas Paldino [.NET/C# MVP]
> - mv*@spam.guard.caspershouse.com
>
> "Sam Martin" <sa*********@yahoo.co.uk> wrote in message
> news:Of*************@tk2msftngp13.phx.gbl...
> > hi all,
> >
> > i've asked a similar question recently regarding accessing the

Windows > > Address Book by creating a wrapper class in C#
> >
> > I need to know whether I'm barking up the wrong the tree?
> >
> > What i've started doing is creating the required structs and declaring > > function calls within the wab32.dll in managed code (C#) but the

problem
> i'm
> > now faced with having to pass an pointer (IntPtr) to an interface
as a > > parameter to one of the functions.
> >
> > Do i have to declare the interfaces i need as c# interfaces? or
can
i need
> > to DllImport them?
> >
> > if you know what i'm talking about then you probably know i don't
> >
> > any help / pointers appreciated
> >
> > tia
> > Sam Martin
> >
> >
>
>



Nov 16 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Roy Smith | last post by:
I've got a C library with about 50 calls in it that I want to wrap in Python. I know I could use some tool like SWIG, but that will give me a too-literal translation; I want to make some...
11
by: yawnmoth | last post by:
word wrapping normally treats some spaces as line feeds, if there hasn't been a line feed for quite a while. so while a string with eighty consecutive a's might not word wrap, a space placed...
5
by: nimdez | last post by:
Hi, I am working on an existing code base in which a lot of data displayed to the user is formatted in tables. Most tables are printed row-by-row using printf() with "%s" print conversion...
2
by: dam_fool_2003 | last post by:
My understanding about wrapping is that we add utilities to a lib function for our specific use. So days ago in the c.l.c I saw a function def as: void * xmalloc (size_t size) { register void...
2
by: Scott | last post by:
I having a problem where I need to turn off the wrapping feature for all columns in my datagrid. Example code would be: <asp:DataGrid id="ResultGrid" runat="server" AutoGenerateColumns="true">...
1
by: mg | last post by:
I set the width of a WebForm Label but do not get line wrapping (see below). What can I do to get line wrapping WebForm1.asp <asp:Labe id="Label1" style="Z-INDEX: 101; LEFT: 40px; POSITION:...
4
by: rodchar | last post by:
Hey all, I have a datagrid that auto-generate the columns. When I run the app some of the column values are wrapping. How do I prevent the values from wrapping? Do I have to use template...
8
by: Nathan | last post by:
I am trying to prevent a horizontal list from wrapping. Each list item is floated with "float: left". Currently I use an ugly hack. I set the width of the list to a large number which is...
9
by: Siv | last post by:
Hi, I am trying to find a wrapping routine for text and not having much luck. The reason I need one is that I am producing a report where the text that was stored in the database was written into...
6
by: Markus Ernst | last post by:
Hi Searching for a possibility to display some text with preserved white space and line breaks, but with long lines being wrapped, I found this CSS declaration, which I found helpful: pre {...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.