Click here to Skip to main content
15,886,873 members
Home / Discussions / C#
   

C#

 
GeneralLaunching C# Applications in IE Pin
mkushner21-Nov-04 5:27
mkushner21-Nov-04 5:27 
GeneralRe: Launching C# Applications in IE Pin
Dave Kreskowiak22-Nov-04 4:23
mveDave Kreskowiak22-Nov-04 4:23 
GeneralTab Key in the DataGrid Pin
Hamada_star21-Nov-04 3:53
Hamada_star21-Nov-04 3:53 
GeneralRe: Tab Key in the DataGrid Pin
Jay Shankar22-Nov-04 15:06
Jay Shankar22-Nov-04 15:06 
GeneralDataGrid RightToLeft Property Pin
Hamada_star21-Nov-04 3:45
Hamada_star21-Nov-04 3:45 
GeneralRe: DataGrid RightToLeft Property Pin
sreejith ss nair21-Nov-04 20:01
sreejith ss nair21-Nov-04 20:01 
GeneralDisposing resources used by MD5CryptoServiceProvider Pin
sillypuppy21-Nov-04 2:52
sillypuppy21-Nov-04 2:52 
GeneralPorting C++ struct to C# (BladeEnc.dll) Pin
Pr1v21-Nov-04 1:44
Pr1v21-Nov-04 1:44 
Im building a C# wrapper for an unmanaged dll (BladeEnc.dll) and im not an expert in this, anyways.

I need to pass the following struct in:
BE_ERR beInitStream( PBE_CONFIG pbeConfig, PDWORD dwSamples, PDWORD dwBufferSize, PHBE_STREAM phbeStream )

typedef struct {

DWORD dwConfig;
union {

struct {

DWORD dwSampleRate;
BYTE byMode;
WORD wBitrate;
BOOL bPrivate;
BOOL bCRC;
BOOL bCopyright;
BOOL bOriginal;

} mp3;

struct {

DWORD dwSampleRate;
BYTE byMode;
WORD wBitrate;
BYTE byEncodingMethod;

} aac;
} format;

} BE_CONFIG, *PBE_CONFIG;

Now i got this in C#:

[StructLayout(LayoutKind.Sequential, Pack = 1)]
internal struct BE_CONFIG
{
public Int32 dwConfig;

public sFormat format;
}

[StructLayout(LayoutKind.Sequential)]
public struct sFormat
{
public sMP3 mp3;
public sAAC aac;
}

[StructLayout(LayoutKind.Sequential)]
public struct sMP3
{
public Int32 dwSampleRate;
public byte byMode;
public Int16 wBitrate;
public bool bPrivate;
public bool bCRC;
public bool bCopyright;
public bool bOriginal;
}

[StructLayout(LayoutKind.Sequential)]
public struct sAAC
{
public Int32 dwSampleRate;
public byte byMode;
public Int16 wBitrate;
public byte byEncodingMethod;
}


Now im testing this function (beInitStream) with the following code:

BE_CONFIG config;
Int32 dwSamples = 0;
Int32 dwBufferSize = 0;

int output;

IntPtr pConfig = IntPtr.Zero;

FileStream fs = new FileStream("C:\\test.mp3", FileMode.Create, FileAccess.Write);

config.dwConfig = BE_CONFIG_MP3;
config.format.mp3.dwSampleRate = 44100;
config.format.mp3.byMode = BE_MP3_MODE_STEREO;
config.format.mp3.bPrivate = false;
config.format.mp3.bCRC = false;
config.format.mp3.bCopyright = false;
config.format.mp3.bOriginal = false;

Marshal.StructureToPtr(Marshal.SizeOf(config), Marshal.AllocHGlobal(pConfig), false);

output = beInitStream(ref pConfig, ref dwSamples, ref dwBufferSize, fs.Handle);

Marshal.FreeHGlobal(pConfig);

fs.Close();

I keep getting the error BE_ERR_INVALID_FORMAT_PARAMETERS, so im assuming that there is something wrong with the structure.

Could anyone confirm and/or help me with this?
QuestionHow Can I Draw lines and text in DataGrid Header Pin
Hamada_star20-Nov-04 22:46
Hamada_star20-Nov-04 22:46 
AnswerRe: How Can I Draw lines and text in DataGrid Header Pin
sreejith ss nair21-Nov-04 16:59
sreejith ss nair21-Nov-04 16:59 
Generalprinting Pin
20-Nov-04 20:51
suss20-Nov-04 20:51 
GeneralRe: printing Pin
Luis Alonso Ramos20-Nov-04 21:26
Luis Alonso Ramos20-Nov-04 21:26 
GeneralRe: printing Pin
sreejith ss nair21-Nov-04 17:07
sreejith ss nair21-Nov-04 17:07 
GeneralCOM+ Transaction and server farms/database clustering Pin
devvvy20-Nov-04 19:10
devvvy20-Nov-04 19:10 
Generalcopying textbox value to another textbox Pin
Member 144657320-Nov-04 18:10
Member 144657320-Nov-04 18:10 
GeneralRe: copying textbox value to another textbox Pin
sreejith ss nair20-Nov-04 18:35
sreejith ss nair20-Nov-04 18:35 
GeneralRe: copying textbox value to another textbox Pin
Charlie Williams20-Nov-04 20:15
Charlie Williams20-Nov-04 20:15 
GeneralRe: copying textbox value to another textbox Pin
Dave Kreskowiak22-Nov-04 4:17
mveDave Kreskowiak22-Nov-04 4:17 
GeneralRe: copying textbox value to another textbox Pin
Charlie Williams20-Nov-04 20:24
Charlie Williams20-Nov-04 20:24 
GeneralRe: copying textbox value to another textbox Pin
Member 144657320-Nov-04 20:50
Member 144657320-Nov-04 20:50 
GeneralClass accesability and namespaces Pin
aspiringCodeMonkey20-Nov-04 17:05
aspiringCodeMonkey20-Nov-04 17:05 
GeneralRe: Class accesability and namespaces Pin
sreejith ss nair20-Nov-04 19:17
sreejith ss nair20-Nov-04 19:17 
GeneralRe: Class accesability and namespaces Pin
Andrew C Armstrong21-Nov-04 11:54
Andrew C Armstrong21-Nov-04 11:54 
GeneralDIVIDE APPLICATION TO FRAMES Pin
binary_c220-Nov-04 16:52
binary_c220-Nov-04 16:52 
GeneralRe: DIVIDE APPLICATION TO FRAMES Pin
Luis Alonso Ramos20-Nov-04 21:30
Luis Alonso Ramos20-Nov-04 21:30 

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.