Click here to Skip to main content
15,918,889 members
Home / Discussions / C#
   

C#

 
GeneralCombobox and SetItemData Pin
Michael P Butler19-Aug-02 23:51
Michael P Butler19-Aug-02 23:51 
GeneralRe: Combobox and SetItemData Pin
Nnamdi Onyeyiri20-Aug-02 0:02
Nnamdi Onyeyiri20-Aug-02 0:02 
GeneralRe: Combobox and SetItemData Pin
Michael P Butler20-Aug-02 0:25
Michael P Butler20-Aug-02 0:25 
GeneralRe: Combobox and SetItemData Pin
Nnamdi Onyeyiri20-Aug-02 0:53
Nnamdi Onyeyiri20-Aug-02 0:53 
GeneralRe: Combobox and SetItemData Pin
Russell Morris20-Aug-02 3:57
Russell Morris20-Aug-02 3:57 
GeneralRe: Combobox and SetItemData Pin
Michael P Butler20-Aug-02 4:19
Michael P Butler20-Aug-02 4:19 
GeneralC# and COM InterOp problems Pin
Rodney S. Foley19-Aug-02 21:03
Rodney S. Foley19-Aug-02 21:03 
GeneralRe: C# and COM InterOp problems Pin
Sijin19-Aug-02 21:15
Sijin19-Aug-02 21:15 
Well you'll have to code the structures by hand, below is an example
//GetVersionEx exported from Kernel32.dll. 
// BOOL GetVersionEx(LPOSVERSIONINFO lpVersionInfo);

//The original structure passed to the function contains the following elements:
   //
   //typedef struct _OSVERSIONINFO
   //        { 
   //           DWORD dwOSVersionInfoSize; 
   //           DWORD dwMajorVersion; 
   //           DWORD dwMinorVersion; 
   //           DWORD dwBuildNumber; 
   //           DWORD dwPlatformId; 
   //           TCHAR szCSDVersion[ 128 ]; 
   //        } OSVERSIONINFO;
   //

using System;
   using System.Runtime.InteropServices;
   
   namespace OSInfo
   {
      class Class1
      {
         [ StructLayout( LayoutKind.Sequential )]
            public class OSVersionInfo 
         {
            public int dwOSVersionInfoSize;
            public int dwMajorVersion;
            public int dwMinorVersion;
            public int dwBuildNumber;
            public int dwPlatformId;
            [ MarshalAs( UnmanagedType.ByValTStr, 
               SizeConst=128 )]    
            public String szCSDVersion;
         }


Each unmanaged DWORD corresponds to a managed int. The embedded fixed-length string TCHAR szCSDVersion[128] must be marshaled by value. The MarshalAs attribute can set the type of string marshaling to use as well as the length of the string. The most appropriate unmanaged type for this case is ByValTStr, which was designed specifically to be used for in-line fixed length character arrays that appear within a structure.



Note the StructLayout Attribute and the MarshalAs Attributes. You'll need to refer to MSDN to find out which UnmanagedType you need to Marshal you Data Members as.

Hope this helps.



May the Source be with you
Sonork ID 100.9997 sijinjoseph

GeneralRe: C# and COM InterOp problems Pin
Stephane Rodriguez.19-Aug-02 21:45
Stephane Rodriguez.19-Aug-02 21:45 
GeneralRe: C# and COM InterOp problems Pin
leppie20-Aug-02 2:14
leppie20-Aug-02 2:14 
GeneralRe: C# and COM InterOp problems Pin
Stephane Rodriguez.20-Aug-02 3:25
Stephane Rodriguez.20-Aug-02 3:25 
GeneralRe: C# and COM InterOp problems Pin
leppie20-Aug-02 4:13
leppie20-Aug-02 4:13 
GeneralRe: C# and COM InterOp problems Pin
Stephane Rodriguez.20-Aug-02 4:49
Stephane Rodriguez.20-Aug-02 4:49 
GeneralRe: C# and COM InterOp problems Pin
Stephane Rodriguez.20-Aug-02 4:52
Stephane Rodriguez.20-Aug-02 4:52 
GeneralRe: C# and COM InterOp problems Pin
leppie20-Aug-02 5:02
leppie20-Aug-02 5:02 
GeneralRe: C# and COM InterOp problems Pin
Stephane Rodriguez.20-Aug-02 6:13
Stephane Rodriguez.20-Aug-02 6:13 
GeneralRe: C# and COM InterOp problems Pin
leppie20-Aug-02 6:50
leppie20-Aug-02 6:50 
GeneralRe: C# and COM InterOp problems Pin
Stephane Rodriguez.20-Aug-02 7:29
Stephane Rodriguez.20-Aug-02 7:29 
GeneralRe: C# and COM InterOp problems Pin
James T. Johnson20-Aug-02 7:32
James T. Johnson20-Aug-02 7:32 
GeneralRe: C# and COM InterOp problems Pin
leppie20-Aug-02 7:40
leppie20-Aug-02 7:40 
GeneralRe: C# and COM InterOp problems Pin
James T. Johnson20-Aug-02 7:47
James T. Johnson20-Aug-02 7:47 
GeneralRe: C# and COM InterOp problems Pin
leppie20-Aug-02 7:57
leppie20-Aug-02 7:57 
GeneralRe: C# and COM InterOp problems Pin
James T. Johnson20-Aug-02 8:01
James T. Johnson20-Aug-02 8:01 
GeneralRe: C# and COM InterOp problems Pin
leppie20-Aug-02 10:33
leppie20-Aug-02 10:33 
GeneralBuild Error Pin
albean19-Aug-02 13:01
albean19-Aug-02 13:01 

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.