Re: Sanity check on call to imported DLL function



On Wed, 10 Dec 2008 17:09:52 -0500, Charles Calvert <cbciv@xxxxxxxxx>
wrote in <2td0k4lr4d78qnrlt230g2rhmdguhgkuq2@xxxxxxx>:

On Wed, 10 Dec 2008 08:27:31 +0530, "G Himangi" <nospam@xxxxxxxxxx>
wrote in <#6OnNMnWJHA.5476@xxxxxxxxxxxxxxxxxxxx>:

[snip]

and the last char array should be defined similar to the way you
defined the DataPID array.

As a char array? I went back and rechecked the documentation and
found something that I had missed before. In the section entitled
"Default Marshaling for Strings", there is a subsection "Strings Used
in Structures" that indicates that it should be a System.String with
the attribute UnmanagedType.ByValTStr and the SizeConst attribute.
Here is the example given:

struct StringInfoT {
TCHAR * f1;
TCHAR f2[256];
};

[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)]
struct StringInfoT {
[MarshalAs(UnmanagedType.LPTStr)] public String f1;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=256)] public String
f2;
}

However, I dont know if this is what is causing the changed member.

It would seem a little odd, given the sequential layout of the struct,
that the last member would affect the first. I'm going to give it a
shot nonetheless. If that doesn't work, I'll try the char array
instead and see what happens.

That didn't help, and I tried this:

[MarshalAs(UnmanagedType.ByValArray, SizeConst=256)]
public char[] szError;

as well, but it didn't solve the problem. I'm not really surprised. I
may be getting the source for the DLL soon, so that should help.

In the meantime, if anyone any other suggestions, I'd appreciate them.

Thanks,
--
Charles Calvert | Web-site Design/Development
Celtic Wolf, Inc. | Software Design/Development
http://www.celticwolf.com/ | Data Conversion
(703) 580-0210 | Project Management
.



Relevant Pages

  • Re: structs for data transfer?
    ... > John Harrison wrote: ... >> Write some code to convert the struct you want to send into a char array. ... or sentinels and delimeters for the ends of strings. ...
    (comp.lang.cpp)
  • Re: Lost in loops
    ... >> I am really stuck with my program that will compare two strings and ... >> assign scores between pairs of letters. ... >> is now in a 2D char array ...
    (comp.lang.java.programmer)
  • Using VC6 code in VS 2005
    ... I'm trying to reuse a database class module that I created with VC 6.0 in ... SqlDriverConnect SqlDriverConnectW" and the compiler balks at my connect ... string being a char array. ... won't accept literal strings or char arrays as parameters. ...
    (microsoft.public.vc.language)
  • Re: structs for data transfer?
    ... > Write some code to turn that char array back into a struct. ... or sentinels and delimeters for the ends of strings. ... figure out how to escape the delimiters if your users type them inside ...
    (comp.lang.cpp)
  • Re: Regular Expression finder
    ... > does anyone know of a tool that would be able to extract the regular ... > expression that corresponds to a set of Strings? ... public String getRegexp{ ... Or did you mean a regexp that matches all of the given Strings ...
    (comp.lang.java.programmer)

Loading