Results 1 to 3 of 3

Thread: IDL Import

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2003
    Location
    Brazil
    Posts
    15

    IDL Import

    Hi,

    I have an IDL file with this structure inside:

    typedef union abc
    {
    int Rogerio;
    LPWSTR valString;
    } _ABC;

    When I generate the type library and make a reference in a vb.net project I cannot see the union members. But if I don't use the LPWSTR valString item, it appears with no problem.

    So my question is: why using LPWSTR in unions make the whole union members not accessible?

    Thanks!

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    You might need to ask C++ guys why !

  3. #3

    Thread Starter
    New Member
    Join Date
    Apr 2003
    Location
    Brazil
    Posts
    15

    Solution

    Hi,

    I've found a way:

    It is possible to declare the variable as a wchar_t * .
    The vb.net see the variable as a System.IntPtr pointer.

    So, now it is necessary only to read the string from the memory pointer. This can be done by : Marshal.PtrToStringAuto(memoryAddress).

    The final code will be like this:

    typedef union abc
    {
    int a;
    wchar_t * b;
    } _abc;

    the vb code:

    dim x as _abc

    ' Reading the data from memory
    Dim MyString As String = Marshal.PtrToStringAuto(x.b)

    That is it!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width