Click here to Skip to main content
15,922,696 members
Home / Discussions / C#
   

C#

 
AnswerRe: Running Sql Script From C#? Pin
Colin Angus Mackay26-Mar-06 3:53
Colin Angus Mackay26-Mar-06 3:53 
QuestionAn attempt was made to load a program with an incorrect format Pin
Colin Angus Mackay26-Mar-06 2:05
Colin Angus Mackay26-Mar-06 2:05 
AnswerRe: An attempt was made to load a program with an incorrect format [SOLVED] Pin
Colin Angus Mackay27-Mar-06 9:17
Colin Angus Mackay27-Mar-06 9:17 
QuestionGrid computing Pin
Mridang Agarwalla26-Mar-06 0:00
Mridang Agarwalla26-Mar-06 0:00 
AnswerRe: Grid computing Pin
Guffa26-Mar-06 1:17
Guffa26-Mar-06 1:17 
QuestionAnother small listview problem Pin
Mridang Agarwalla25-Mar-06 23:50
Mridang Agarwalla25-Mar-06 23:50 
AnswerRe: Another small listview problem Pin
Stefan Troschuetz25-Mar-06 23:54
Stefan Troschuetz25-Mar-06 23:54 
GeneralRe: Another small listview problem Pin
Mridang Agarwalla26-Mar-06 0:13
Mridang Agarwalla26-Mar-06 0:13 
AnswerRe: Another small listview problem Pin
Ravi Bhavnani26-Mar-06 5:01
professionalRavi Bhavnani26-Mar-06 5:01 
QuestionCreating and placing controls on runtime and referencing via SQL string Pin
fracalifa25-Mar-06 23:04
fracalifa25-Mar-06 23:04 
QuestionImage properties Pin
valiovalio25-Mar-06 22:46
valiovalio25-Mar-06 22:46 
AnswerRe: Image properties Pin
Guffa25-Mar-06 23:56
Guffa25-Mar-06 23:56 
GeneralRe: Image properties Pin
valiovalio26-Mar-06 2:05
valiovalio26-Mar-06 2:05 
Questionresizing a button thru mouse???????? Pin
rani baji25-Mar-06 22:20
rani baji25-Mar-06 22:20 
QuestionC# and Inheritance Pin
hung_ngole25-Mar-06 22:00
hung_ngole25-Mar-06 22:00 
AnswerRe: C# and Inheritance Pin
Guffa26-Mar-06 0:10
Guffa26-Mar-06 0:10 
QuestionHow to draw text in Standard mode in CF? Pin
pmasknguyen25-Mar-06 21:48
pmasknguyen25-Mar-06 21:48 
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);

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.