Click here to Skip to main content
15,918,668 members
Home / Discussions / C#
   

C#

 
QuestionRunning Sql Script From C#? Pin
majidbhutta26-Mar-06 3:43
majidbhutta26-Mar-06 3:43 
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 
I am trying to save a toolbar state to registry for later restore. But i seem unable to work with the Win32 API correctly. Can someone help? The problem is with the TBSAVEPARAMS struct. It wants a handle to the registry key (HKEY_LOCAL_MACHINE in this case) but where do i get this? I have tried passing the HKEY_LOCAL_MACHINE const 0x80000002 but i get a memory cannot be read error when i execute SendMessage TB_SAVERESTORE. I have tried the NET Registry.LocalMachine but i am unable to turn this into a pointer needed for the struct.

So what options are available? Is this impossible in NET? Below is the code i am using.

[StructLayout(LayoutKind.Sequential)]
public struct TBSAVEPARAMS
{
public UIntPtr hkr;
public string pszSubKey;
public string pszValueName;
}

[DllImport("user32.dll")]
public static extern int SendMessage(
IntPtr hWnd,
uint msg,
bool wParam,
Win32Struct.TBSAVEPARAMS lParam);

// open registrykey
// create key if needed
RegistryKey key = null;
string regKey = @"SOFTWARE\TEST";
key = Registry.LocalMachine.OpenSubKey(regKey, true);
// check errors
if (key == null)
{
return;
}
// close registry key
key.Close();

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

// set up restore struct
Win32Struct.TBSAVEPARAMS tbSaveParams = new Win32Struct.TBSAVEPARAMS();
tbSaveParams.hkr = (UIntPtr)Win32Const.HKEY_LOCAL_MACHINE;
tbSaveParams.pszSubKey = regKey;
tbSaveParams.pszValueName = "Toolbar";

// save tray icon state
int result = Win32Windows.SendMessage(hWndToolBar,
(uint)Win32Const.TB_SAVERESTOREA, true, tbSaveParams);
Debug.WriteLine("result: " + result);



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.