Click here to Skip to main content
15,881,172 members
Home / Discussions / C#
   

C#

 
GeneralRe: Best method for syntax highlighting Pin
WebMaster17-Jul-09 4:59
WebMaster17-Jul-09 4:59 
GeneralRe: Best method for syntax highlighting Pin
Luc Pattyn17-Jul-09 11:15
sitebuilderLuc Pattyn17-Jul-09 11:15 
GeneralRe: Best method for syntax highlighting Pin
WebMaster17-Jul-09 21:39
WebMaster17-Jul-09 21:39 
GeneralRe: Best method for syntax highlighting Pin
WebMaster28-Jul-09 8:41
WebMaster28-Jul-09 8:41 
GeneralRe: Best method for syntax highlighting Pin
Luc Pattyn28-Jul-09 22:37
sitebuilderLuc Pattyn28-Jul-09 22:37 
GeneralRe: Best method for syntax highlighting Pin
Kevin Marois14-Jul-09 9:08
professionalKevin Marois14-Jul-09 9:08 
GeneralRe: Best method for syntax highlighting Pin
Adam R Harris14-Jul-09 10:32
Adam R Harris14-Jul-09 10:32 
QuestionPassing a pointer to array of structs via P/Invoke Pin
Klempie14-Jul-09 6:29
Klempie14-Jul-09 6:29 
I'm passing an array of structs to an unmanaged method and just want to make sure that what I'm doing is correct.

Let's assume I have a struct defined as

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public struct MyStruct
{
    public MyStruct(string Name, uint Index, MyEnum flag)
    {
          //some code
    }

    [MarshalAs(UnmanagedType.LPTStr)]
    public string mName;
    public uint sIndex;
    [MarshalAs(UnmanagedType.U4)]
    public MyEnum mflag;
}


where MyEnum is some enum deriving from uint.

The calling code creates an array of these structs like this:

MyStruct [] structs = 
{
     new MyStruct("BEN", 0, MyEnum.FIRST),
     new MyStruct("VAL", 1, MyEnum.FOURTH),
     new MyStruct("ROG", 2, MyEnum.SECOND)
};


I then pass this array to the managed function which looks like this:

public static extern int SetMyStructs([MarshalAs(UnmanagedType.LPArray)] MyStruct [] structs)


which is supposed to map to the unmanaged function of:

int SetMyStructs(MyStruct * structs)


SetMyStructs is returning values indicating that the function is not executing correctly. Is passing an array of structs containing strings and integers possible and if so am I using the correct marshalling attributes? I just want to eliminate this array of structs as a possible reason for the failing function.
Questioncustomizing a ToolStripTextBox Pin
Jim Crafton14-Jul-09 5:38
Jim Crafton14-Jul-09 5:38 
AnswerRe: customizing a ToolStripTextBox Pin
Henry Minute14-Jul-09 5:53
Henry Minute14-Jul-09 5:53 
GeneralRe: customizing a ToolStripTextBox Pin
Jim Crafton14-Jul-09 6:04
Jim Crafton14-Jul-09 6:04 
GeneralRe: customizing a ToolStripTextBox Pin
DaveyM6914-Jul-09 6:26
professionalDaveyM6914-Jul-09 6:26 
Questionreturn string Pin
AndyInUK14-Jul-09 5:22
AndyInUK14-Jul-09 5:22 
AnswerRe: return string Pin
Simon P Stevens14-Jul-09 5:28
Simon P Stevens14-Jul-09 5:28 
GeneralRe: return string Pin
AndyInUK14-Jul-09 5:36
AndyInUK14-Jul-09 5:36 
AnswerRe: return string PinPopular
Luc Pattyn14-Jul-09 5:42
sitebuilderLuc Pattyn14-Jul-09 5:42 
GeneralRe: return string Pin
AndyInUK14-Jul-09 6:19
AndyInUK14-Jul-09 6:19 
GeneralRe: return string Pin
Luc Pattyn14-Jul-09 6:27
sitebuilderLuc Pattyn14-Jul-09 6:27 
GeneralRe: return string Pin
musefan14-Jul-09 7:10
musefan14-Jul-09 7:10 
GeneralRe: return string Pin
Joe Woodbury14-Jul-09 6:48
professionalJoe Woodbury14-Jul-09 6:48 
GeneralRe: return string Pin
musefan14-Jul-09 6:57
musefan14-Jul-09 6:57 
GeneralRe: return string Pin
Luc Pattyn14-Jul-09 7:04
sitebuilderLuc Pattyn14-Jul-09 7:04 
GeneralRe: return string [modified] Pin
Joe Woodbury14-Jul-09 7:07
professionalJoe Woodbury14-Jul-09 7:07 
GeneralRe: return string Pin
AndyInUK15-Jul-09 5:20
AndyInUK15-Jul-09 5:20 
GeneralRe: return string Pin
Joe Woodbury15-Jul-09 5:35
professionalJoe Woodbury15-Jul-09 5:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.