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 / Compact Framework / March 2004

Tip: Looking for answers? Try searching our database.

P/Invoke - TAPI - LINEDEVCAPS-structure!?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Danyel Meyer - dialog-it GmbH - 04 Mar 2004 11:08 GMT
Hallo...

I?ve got quite confused while trying to P/Invoke TAPI?s lineGetDeviceCaps. I
find it very difficult to marshal the LINEDEVCAPS-structure, which is
defined as:

--8<--
typedef struct linedevcaps_tag
{
   DWORD    ... [many many DWORDs]
} LINEDEVCAPS, FAR *LPLINEDEVCAPS;
-->8--

As far as I understand it, I have to use Integers for the DWORD-values. What
I don?t understand is, how can I e.g. get the lineName from this structure,
when there are only integers in it? Furthermore, what does "FAR" in the type
definition mean (I?m not quite familiar with C)?
How do I have to imagine what this structure looks like ans how it?s values
are stored?

Plaes, help before my head explodes ;) ...I just don?t get what happens
there...

Signature

Danyel Meyer
-------------------------------------------
 dialog-it GmbH
 R?llingh?user Strasse 55a
 31061 Alfeld/Leine

 Tel  +49 (0) 5181 900 814
 Fax  +49 (0) 5181 900 815
 E-Mail  danyel.meyer <at> dialog-it.de

Paul G. Tobey [eMVP] - 04 Mar 2004 15:38 GMT
When you call TSPI_lineGetDevCaps and pass it an instance of the structure,
the function may tell you that the block of memory you passed is too small.
That is, the explicit fields declared as being part of the structure are
just the 'header' part of the memory layout of the information.  After those
fields, there is an indeterminate amount of extra memory required for
things, like the name, which may vary in length.  The dwLineNameOffset field
of the structure tells you how many bytes into the structure the start of
the line name string is (it will begin after the last explicit field shown
in the structure declaration), and the dwLineNameSize field tells you how
many bytes of string data are stored there for the name.  To actually
extract that data, you'll need to get the bytes at that offset and for that
length from the structure and convert them to a string.

This is a case where representing the structure in memory as a byte array is
probably the best way to go.  That way, when you create it and call
TSPI_lineGetDevCaps and it returns an indication that there is not enough
space, you can internally extend the array and try again.  There are
numerous examples of this use-a-byte-array-as-a-structure-for-P/Invoke in
the OpenNetCF framework, as well as in the archives of this newsgroups.

Paul T.

> Hallo...
>
[quoted text clipped - 18 lines]
> Plaes, help before my head explodes ;) ...I just don?t get what happens
> there...
Danyel Meyer - dialog-it GmbH - 05 Mar 2004 12:48 GMT
Thanks Paul,

That was what I just missed. To imagine the structures defined fields as a
kind of header was what came to my mind, but I wanted to get feedback if
it?s right.
I now was able to use the structure the way you recommended.

Signature

Danyel Meyer
-------------------------------------------
 dialog-it GmbH
 R?llingh?user Strasse 55a
 31061 Alfeld/Leine

 Tel  +49 (0) 5181 900 814
 Fax  +49 (0) 5181 900 815
 E-Mail  danyel.meyer <at> dialog-it.de

> When you call TSPI_lineGetDevCaps and pass it an instance of the structure,
> the function may tell you that the block of memory you passed is too small.
[quoted text clipped - 45 lines]
> > Plaes, help before my head explodes ;) ...I just don?t get what happens
> > there...
Alex Feinman [MVP] - 04 Mar 2004 16:28 GMT
I think you might find it easier to use a prebuilt wrapper.
Take a look at http://www.alexfeinman.com/downloads.asp?doc=tapi1.1.zip
If you decide to take a look at it, I would appreciate a feedback - I'm
trying to freeze the feature set so that a beta can be included into
OpenNETCF SDF

> Hallo...
>
[quoted text clipped - 18 lines]
> Plaes, help before my head explodes ;) ...I just don?t get what happens
> there...
Danyel Meyer - dialog-it GmbH - 05 Mar 2004 12:51 GMT
Hallo Alex,

Thanks for the hint to your wrapper. I have taken a look at it, and I indeed
thought about using it. But my requirements untli now are just a small
subset of it, so I decided to code it myself. I just need to monitor the
cell line to recieve data about beginning and ending calls.
I?ve just got it done, and your code was of great help.

Signature

Danyel Meyer
-------------------------------------------
 dialog-it GmbH
 R?llingh?user Strasse 55a
 31061 Alfeld/Leine

 Tel  +49 (0) 5181 900 814
 Fax  +49 (0) 5181 900 815
 E-Mail  danyel.meyer <at> dialog-it.de

> I think you might find it easier to use a prebuilt wrapper.
> Take a look at http://www.alexfeinman.com/downloads.asp?doc=tapi1.1.zip
[quoted text clipped - 29 lines]
> > Plaes, help before my head explodes ;) ...I just don?t get what happens
> > there...

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.