Working with structures - the pure .net way
Posted: Fri Jul 27, 2018 10:21 am
Guys,
1.While playing with structures i´ve noticed that the compiler throws an misleading error when you pass
a different structure than the callee expects: "error XS1620: Argument 1 must be passed with the 'ref' keyword"
Such an misleading XS1620 error happens when you do something like this:
IF GetVersionEx ( struInfoExW ) // wrong structure - OSVERSIONINFOEXW
instead of:
IF GetVersionEx ( struInfoEx ) // correct structure - OSVERSIONINFOEX
2. I´m able to compile a "_DLL" import not only as "ANSI" or "UNICODE", but with "AUTO" too, though "AUTO" seems to have no effect at runtime. For what is "AUTO" good for in this context ?
There are some more notes in the attached app, so i thing it should be easy to follow what i´m doing and how i´m using the import possibilities
"_DLL" / "[DllImport" and the charsets Ansi,UniCode and Auto.
BTW I. the StructureTest.viaef has no references to any Vulcan dll or X# dll. Also, the warning 0170 is disabeld via "/nowarn:170" . The structure member "szCSDVersion" is only filled when you´re running Win7 SP1 or Vista SPx. Win 8.1 and Win 10 have no servicepacks.
BTW II. very nice to be able to do something like this now:
? "OutPut: " + lStart + " " + dwStart
// Of course, lStart is a LOGIC and dwStart a DWORD
Any comments/corrections are welcome.
regards
Karl-Heinz
1.While playing with structures i´ve noticed that the compiler throws an misleading error when you pass
a different structure than the callee expects: "error XS1620: Argument 1 must be passed with the 'ref' keyword"
Such an misleading XS1620 error happens when you do something like this:
IF GetVersionEx ( struInfoExW ) // wrong structure - OSVERSIONINFOEXW
instead of:
IF GetVersionEx ( struInfoEx ) // correct structure - OSVERSIONINFOEX
2. I´m able to compile a "_DLL" import not only as "ANSI" or "UNICODE", but with "AUTO" too, though "AUTO" seems to have no effect at runtime. For what is "AUTO" good for in this context ?
There are some more notes in the attached app, so i thing it should be easy to follow what i´m doing and how i´m using the import possibilities
"_DLL" / "[DllImport" and the charsets Ansi,UniCode and Auto.
BTW I. the StructureTest.viaef has no references to any Vulcan dll or X# dll. Also, the warning 0170 is disabeld via "/nowarn:170" . The structure member "szCSDVersion" is only filled when you´re running Win7 SP1 or Vista SPx. Win 8.1 and Win 10 have no servicepacks.
BTW II. very nice to be able to do something like this now:
? "OutPut: " + lStart + " " + dwStart
// Of course, lStart is a LOGIC and dwStart a DWORD
Any comments/corrections are welcome.
regards
Karl-Heinz