Click here to Skip to main content
16,007,885 members
Home / Discussions / C#
   

C#

 
GeneralRe: Passing an int array by reference to a shell function - how? Pin
iliyang15-Jun-05 0:20
iliyang15-Jun-05 0:20 
GeneralRe: Passing an int array by reference to a shell function - how? Pin
jjansen15-Jun-05 0:39
jjansen15-Jun-05 0:39 
GeneralRe: Passing an int array by reference to a shell function - how? Pin
iliyang15-Jun-05 1:13
iliyang15-Jun-05 1:13 
GeneralRe: Passing an int array by reference to a shell function - how? Pin
jjansen15-Jun-05 2:11
jjansen15-Jun-05 2:11 
GeneralRe: Passing an int array by reference to a shell function - how? Pin
iliyang15-Jun-05 2:24
iliyang15-Jun-05 2:24 
GeneralRe: Passing an int array by reference to a shell function - how? Pin
jjansen15-Jun-05 2:36
jjansen15-Jun-05 2:36 
GeneralRe: Passing an int array by reference to a shell function - how? Pin
iliyang15-Jun-05 2:54
iliyang15-Jun-05 2:54 
GeneralRe: Passing an int array by reference to a shell function - how? Pin
jjansen15-Jun-05 3:28
jjansen15-Jun-05 3:28 
You're right, my mistake. I wrongly assumed that the Copy method returns a pointer to the array. On second thought this isn't what Copy does at all. Instead you have to allocate some space yourself using Marshal.AllocHGlobal with the appropriate number of bytes. This gives you a valid IntPtr.

int Nr = ...; // number of elements in array<br />
int[] MyArray = new int[Nr];<br />
IntPtr MyPtr = Marshal.AllocHGlobal(Nr * sizeof(int))


Then call SendMessage with MyPtr.
Next use the Copy(IntPtr MyPtr, int[] MyArray, 0, MyArray.Length) method.
Finally use Marshal.FreeHAlloc.
GeneralRe: Passing an int array by reference to a shell function - how? Pin
iliyang15-Jun-05 3:46
iliyang15-Jun-05 3:46 
GeneralRe: Passing an int array by reference to a shell function - how? Pin
jjansen15-Jun-05 4:00
jjansen15-Jun-05 4:00 
GeneralHelp - "Specified cast is not valid" Pin
Anthony Mushrow14-Jun-05 23:06
professionalAnthony Mushrow14-Jun-05 23:06 
GeneralRe: Help - &quot;Specified cast is not valid&quot; Pin
jjansen14-Jun-05 23:25
jjansen14-Jun-05 23:25 
GeneralRe: Help - "Specified cast is not valid" Pin
Anthony Mushrow14-Jun-05 23:33
professionalAnthony Mushrow14-Jun-05 23:33 
GeneralRe: Help - &quot;Specified cast is not valid&quot; Pin
jjansen14-Jun-05 23:43
jjansen14-Jun-05 23:43 
GeneralRe: Help - &quot;Specified cast is not valid&quot; Pin
Christian Graus14-Jun-05 23:41
protectorChristian Graus14-Jun-05 23:41 
GeneralRe: Help - &quot;Specified cast is not valid&quot; Pin
Vasudevan Deepak Kumar15-Jun-05 2:07
Vasudevan Deepak Kumar15-Jun-05 2:07 
GeneralRe: Help - &quot;Specified cast is not valid&quot; Pin
jjansen15-Jun-05 2:26
jjansen15-Jun-05 2:26 
GeneralRe: Help - &quot;Specified cast is not valid&quot; Pin
Anonymous15-Jun-05 13:02
Anonymous15-Jun-05 13:02 
GeneralMore help!! Pin
Anthony Mushrow16-Jun-05 1:03
professionalAnthony Mushrow16-Jun-05 1:03 
GeneralCreating a vectorized metafile (wmf) Pin
jjansen14-Jun-05 22:55
jjansen14-Jun-05 22:55 
QuestionHow can display a log of what's happening? Pin
Gavin_RTE14-Jun-05 22:27
Gavin_RTE14-Jun-05 22:27 
AnswerRe: How can display a log of what's happening? Pin
nemopeti14-Jun-05 22:49
nemopeti14-Jun-05 22:49 
GeneralRe: How can display a log of what's happening? Pin
Gavin_RTE14-Jun-05 23:25
Gavin_RTE14-Jun-05 23:25 
GeneralHelp needed!!! FileSystemWatcher Pin
g3e14-Jun-05 21:57
g3e14-Jun-05 21:57 
GeneralRe: Help needed!!! FileSystemWatcher Pin
mav.northwind15-Jun-05 1:27
mav.northwind15-Jun-05 1:27 

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.