Click here to Skip to main content
15,906,097 members
Home / Discussions / C#
   

C#

 
Questionlistview problem Pin
Mridang Agarwalla25-Mar-06 16:49
Mridang Agarwalla25-Mar-06 16:49 
AnswerRe: listview problem [Modified] Pin
Ravi Bhavnani25-Mar-06 16:54
professionalRavi Bhavnani25-Mar-06 16:54 
AnswerRe: listview problem Pin
Sean8925-Mar-06 16:57
Sean8925-Mar-06 16:57 
GeneralRe: listview problem Pin
Mridang Agarwalla25-Mar-06 17:38
Mridang Agarwalla25-Mar-06 17:38 
GeneralRe: listview problem Pin
cbhkenshin25-Mar-06 18:36
cbhkenshin25-Mar-06 18:36 
QuestionGIS in the C# Pin
taybalo25-Mar-06 15:53
taybalo25-Mar-06 15:53 
QuestionSaving a Toolbar State to Registry? Pin
redfish3425-Mar-06 12:27
redfish3425-Mar-06 12:27 
AnswerSome Progress, Still Need Help Pin
redfish3425-Mar-06 17:03
redfish3425-Mar-06 17:03 
I found that one has to us process shared memory when communicating with windows OS toolbars; I thought this only applied when reading back structs in a SendMessage. Below is update of my code. I do not get any errors this time, but nothing happens. No registry key value is created, nothing. I probably need someone with PInvoke experience to OK my code ot NOT. That would help.

// get toolbar handle
IntPtr hWndToolBar = TrayIcons.GetIconTrayWnd();

// get handle to other process
// open process for all access or get access denied error
int processID = 0;
int threadID = Win32ProcessThread.GetWindowThreadProcessId(
hWndToolBar, ref processID);
IntPtr hProcess = Win32ProcessThread.OpenProcess(
Win32Const.PROCESS_ALL_ACCESS, false, processID);

// set up shared memory for struct
// make it big enough to hold dynamic data
int bufferSize = 16000;
IntPtr hGlobalBuffer = Win32Memory.VirtualAllocEx(
hProcess, IntPtr.Zero, bufferSize,
Win32Const.MEM_RESERVE | Win32Const.MEM_COMMIT,
Win32Const.PAGE_READWRITE);
// allocate local memory to hold struct
IntPtr hLocalBuffer = Marshal.AllocHGlobal(bufferSize);

// set up save struct
Win32Struct.TBSAVEPARAMS tbSaveParams = new Win32Struct.TBSAVEPARAMS();
string regKey = @"SOFTWARE\TEST";
tbSaveParams.hkr = (UIntPtr)Win32Const.HKEY_LOCAL_MACHINE;
tbSaveParams.pszSubKey = regKey;
tbSaveParams.pszValueName = "IconsBackup";

// convert struct to pointer
Marshal.StructureToPtr(tbSaveParams, hLocalBuffer, false);
// put struct in place
Win32Memory.WriteProcessMemory(hProcess, hGlobalBuffer,
hLocalBuffer, bufferSize, 0);

// save tray icon state
// no return value
Win32Windows.SendMessage(hWndToolBar,
(uint)Win32Const.TB_SAVERESTOREA, true, hLocalBuffer);

// clean up
Win32Memory.VirtualFreeEx(hProcess, hGlobalBuffer,
bufferSize, Win32Const.MEM_RELEASE);
Marshal.FreeHGlobal(hLocalBuffer);
Win32ProcessThread.CloseHandle(hProcess);
QuestionExplain please... Pin
KORCARI25-Mar-06 11:26
KORCARI25-Mar-06 11:26 
AnswerRe: Explain please... Pin
Sean8925-Mar-06 11:59
Sean8925-Mar-06 11:59 
AnswerRe: Explain please... Pin
Guffa25-Mar-06 12:01
Guffa25-Mar-06 12:01 
QuestionMessagbox, listbox or combobox Pin
Yakup Ertas25-Mar-06 9:52
Yakup Ertas25-Mar-06 9:52 
Questioni image in listview Pin
yosba22125-Mar-06 9:48
yosba22125-Mar-06 9:48 
AnswerRe: i image in listview Pin
redfish3425-Mar-06 12:33
redfish3425-Mar-06 12:33 
AnswerRe: i image in listview Pin
Luis Alonso Ramos26-Mar-06 17:40
Luis Alonso Ramos26-Mar-06 17:40 
QuestionCollectionEditor Code Clean Up Pin
cnich2325-Mar-06 9:34
cnich2325-Mar-06 9:34 
QuestionDrawing Shapes Pin
Anindya Chatterjee25-Mar-06 9:26
Anindya Chatterjee25-Mar-06 9:26 
QuestionHow to make a searh function? Pin
AeQuitaZ25-Mar-06 8:19
AeQuitaZ25-Mar-06 8:19 
AnswerRe: How to make a searh function? Pin
Luis Alonso Ramos26-Mar-06 17:43
Luis Alonso Ramos26-Mar-06 17:43 
QuestionSupressing a MessageBox Pin
eggie525-Mar-06 7:40
eggie525-Mar-06 7:40 
AnswerRe: Supressing a MessageBox Pin
Ravi Bhavnani25-Mar-06 8:06
professionalRavi Bhavnani25-Mar-06 8:06 
GeneralRe: Supressing a MessageBox Pin
eggie525-Mar-06 8:08
eggie525-Mar-06 8:08 
AnswerRe: Supressing a MessageBox Pin
Luis Alonso Ramos25-Mar-06 8:59
Luis Alonso Ramos25-Mar-06 8:59 
GeneralRe: Supressing a MessageBox Pin
cnich2325-Mar-06 9:38
cnich2325-Mar-06 9:38 
GeneralRe: Supressing a MessageBox Pin
Luis Alonso Ramos25-Mar-06 9:41
Luis Alonso Ramos25-Mar-06 9:41 

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.