Click here to Skip to main content
16,012,223 members
Home / Discussions / C#
   

C#

 
GeneralRe: Gui Container Tools Pin
wgroves8-Dec-06 2:44
wgroves8-Dec-06 2:44 
QuestionInstall service programmatically Pin
kwp8-Dec-06 1:54
kwp8-Dec-06 1:54 
QuestionRounding numbers Pin
matthias s.8-Dec-06 1:06
matthias s.8-Dec-06 1:06 
AnswerRe: Rounding numbers Pin
J4amieC8-Dec-06 1:08
J4amieC8-Dec-06 1:08 
GeneralRe: Rounding numbers Pin
matthias s.8-Dec-06 1:13
matthias s.8-Dec-06 1:13 
AnswerRe: Rounding numbers Pin
ednrgc8-Dec-06 3:23
ednrgc8-Dec-06 3:23 
QuestionSafely create System.Drawing.Bitmap from managed int[] Pin
N-O-R-B-E-R-T8-Dec-06 0:59
N-O-R-B-E-R-T8-Dec-06 0:59 
AnswerRe: Safely create System.Drawing.Bitmap from managed int[] Pin
Luc Pattyn8-Dec-06 1:46
sitebuilderLuc Pattyn8-Dec-06 1:46 
Hi,

I have not done this for bitmaps yet, but passing a sound array to the unmanaged
function PlaySound() requires a pointer to a data object (array) that can not be
moved by the GC; see GCHandle and pinning in code snippet below.

// play sound from a sound resource
Stream stream=type.Assembly.GetManifestResourceStream(resourceName);
int len=(int)stream.Length;
byte[] buf=new byte[len];
stream.Read(buf, 0, len);
GCHandle handle=GCHandle.Alloc(buf);
IntPtr ptr=Marshal.UnsafeAddrOfPinnedArrayElement(buf, 0);
int res=sndPlaySound(ptr, 4);   // SND_MEMORY
handle.Free();

I expect what you need is very similar to the above.
Don't forget to free the handle when the pinning is no longer needed (otherwise
the GC can not collect or even move it, possibly ending up in out-of-memory problems).

Smile | :)

Luc Pattyn

GeneralRe: Safely create System.Drawing.Bitmap from managed int[] Pin
N-O-R-B-E-R-T9-Dec-06 2:22
N-O-R-B-E-R-T9-Dec-06 2:22 
GeneralRe: Safely create System.Drawing.Bitmap from managed int[] Pin
Luc Pattyn9-Dec-06 9:20
sitebuilderLuc Pattyn9-Dec-06 9:20 
GeneralRe: Safely create System.Drawing.Bitmap from managed int[] Pin
N-O-R-B-E-R-T9-Dec-06 12:44
N-O-R-B-E-R-T9-Dec-06 12:44 
QuestionForm Layout SDI or MDI Pin
h@s@n8-Dec-06 0:26
h@s@n8-Dec-06 0:26 
AnswerRe: Form Layout SDI or MDI Pin
Bhupi Bhai8-Dec-06 0:56
Bhupi Bhai8-Dec-06 0:56 
AnswerRe: Form Layout SDI or MDI Pin
Pete O'Hanlon8-Dec-06 1:20
mvePete O'Hanlon8-Dec-06 1:20 
GeneralRe: Form Layout SDI or MDI Pin
h@s@n8-Dec-06 2:40
h@s@n8-Dec-06 2:40 
GeneralRe: Form Layout SDI or MDI Pin
Pete O'Hanlon8-Dec-06 2:58
mvePete O'Hanlon8-Dec-06 2:58 
GeneralRe: Form Layout SDI or MDI Pin
h@s@n8-Dec-06 5:21
h@s@n8-Dec-06 5:21 
QuestionRichEdit that like "VS.net Code Editor" Pin
god4k7-Dec-06 23:25
god4k7-Dec-06 23:25 
AnswerRe: RichEdit that like "VS.net Code Editor" Pin
Pete O'Hanlon7-Dec-06 23:42
mvePete O'Hanlon7-Dec-06 23:42 
GeneralRe: RichEdit that like "VS.net Code Editor" Pin
god4k9-Dec-06 1:39
god4k9-Dec-06 1:39 
QuestionRefreshing a page at frequent intervals Pin
meeram3957-Dec-06 23:23
meeram3957-Dec-06 23:23 
AnswerRe: Refreshing a page at frequent intervals Pin
Pete O'Hanlon7-Dec-06 23:45
mvePete O'Hanlon7-Dec-06 23:45 
GeneralRe: Refreshing a page at frequent intervals Pin
meeram3958-Dec-06 1:29
meeram3958-Dec-06 1:29 
GeneralRe: Refreshing a page at frequent intervals Pin
Pete O'Hanlon8-Dec-06 2:27
mvePete O'Hanlon8-Dec-06 2:27 
GeneralRe: Refreshing a page at frequent intervals Pin
meeram39511-Dec-06 23:54
meeram39511-Dec-06 23:54 

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.