![]() |
|
|
|
|
|
|
2
12th April 23:28
External User
Posts: 1
|
Hi Jan,
I'm not sure if the default marshaler will copy the modified string back to the unmanaged memory area. In this situation I suggest you defining this method as [PreserveSig] int GetOverlayInfo( IntPtr iconFileBuffer, int iconFileBufferSize, out int iconIndex, out uint flags); and doing marshalling by yourself. public int GetOverlayInfo( IntPtr iconFileBuffer, int iconFileBufferSize, out int iconIndex, out uint flags) { System.Diagnostics.Debug.WriteLine(string.Format(" GetOverlayInfo::{0}",iconF ileBuffer)); System.Diagnostics.Debug.WriteLine(string.Format(" GetOverlayInfo::{0}",iconF ileBufferSize)); string fname = @"c:\overlay.ico"; int bytesCount = System.Text.Encoding.Unicode.GetByteCount(fname); System.Diagnostics.Debug.WriteLine(string.Format(" GetOverlayInfo::{0}",bytes Count)); byte[] bytes = System.Text.Encoding.Unicode.GetBytes(fname); if (bytes.Length + 2 < iconFileBufferSize) { for(int i = 0; i < bytes.Length; i++) { Marshal.WriteByte(iconFileBuffer,i,bytes[i]); } //write the "\0\0" Marshal.WriteByte(iconFileBuffer,bytes.Length,0); Marshal.WriteByte(iconFileBuffer,bytes.Length+1,0) ; } iconIndex = 0; flags = 1; // ISIOI_ICONFILE return 0; // S_OK } Does it resolve your problem? If you have any problem on this issue, please feel free to reply this thread. Thanks! Best regards, Ying-Shen Yu [MSFT] Microsoft Community Support Get Secure! - www.microsoft.com/security This posting is provided "AS IS" with no warranties and confers no rights. This mail should not be replied directly, please remove the word "online" before sending mail. |
|
|
|