|
Roger Wright wrote: Question About Class Properties
Dito all for structs.
|
|
|
|
|
I am having a little bit of a problem. I am trying to get installed software from computers. The problem is when running it from a x86 machine it defaults to the wow6432node on the x64 server. What I really need is to read both the regular AND the wow6432node for all software installed on the machine.
Here is what I am doing:
string registryKey = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
try
{
Microsoft.Win32.RegistryKey key = Microsoft.Win32.RegistryKey.OpenRemoteBaseKey(Microsoft.Win32.RegistryHive.LocalMachine,
dnsName.ToString());
Microsoft.Win32.RegistryKey subKey = key.OpenSubKey(registryKey);
foreach (string foundValues in subKey.GetSubKeyNames())
{
Microsoft.Win32.RegistryKey val = subKey.OpenSubKey(foundValues);
if (!(val.GetValue("DisplayName") == null))
{
ListViewItem item = new ListViewItem();
item.Text = val.GetValue("DisplayName").ToString();
if (val.GetValue("InstallLocation") != null)
item.SubItems.Add(val.GetValue("InstallLocation").ToString());
Invoke((Action)(() => { lstApplications.Items.Add(item); }));
}
}
}
catch (Exception) { }
finally
{
Invoke((Action)(() => { picProgressApps.Visible = false; }));
}
|
|
|
|
|
You're trying to read the 64-bit registry from a 32-bit machine?? You have to do it from a 64-bit app running on a 64-bit machine for that to work.
If you want to know what's installed on a machine in a more generic way, use WMI instead. Google for "Win32_Product" and "Win32_QuickFixEngineering" to get installed software and HotFixes.
|
|
|
|
|
Thanks! I was actually reading about WMI after I posted my first discussion. I took a look at http://msdn.microsoft.com/en-us/library/aa394378(VS.85).aspx[^] and it has everything I need! I was able to read only from the wow6432node with the previous code but with WMI it lets me read all installed software
Does the WMI do basically the same in checking uninstallers or is it checking installed applications some other way? I guess I'm wondering why WMI can do it but remote registry can't
|
|
|
|
|
The WMI query executes on the remote machine, in it's native envrironment, not on your machine. The results are packed into standardized, platform independant objects (WMI classes) and returned to the caller. That's why it works and reading the registry directly doesn't.
|
|
|
|
|
Ohh I see. Thank you for explaining that to me.
Have a good day!
|
|
|
|
|
I am writing a program that is going to be operated with an IR controller. In the program Form1 creates a new form Form2.
Form2 dlg = new Form2(fname);
if (dlg.ShowDialog() == DialogResult.OK)
{
}
Unfortunatly the new form will not receive input unless I click on it with the mouse to make it active. I have tried various commands but in order to make the new form receive the IR commands I must click on the form with the mouse. How can I activate the form programatically.
public Form2(string temp)
{
InitializeComponent();
//this.Focus(); // Tried these
//this.Activate();
//this.BringToFront();
}
|
|
|
|
|
Hi George,
electriac wrote: the new form will not receive input unless I click on it
I don't think this is correct. What probably happened is the Control with the lowest TabIndex isn't the one you want it to be. Try playing around with TabIndex (and check TabStop is still at its default value of true).
If all that does not help, experiment with Focus, Activate, BringToFront inside the Shown handler, the constructor is too soon for these.
Regards,
|
|
|
|
|
Tried delaying commands with a timer. NG. Unless I click on the form the IR commands are written to my source code. So the compiler is the active form.
|
|
|
|
|
electriac wrote: the compiler is the active form
Each WinForm application has an active window; what you are saying is somehow your IDE (Visual Studio?) is active instead of your app itself. That is abnormal; what do you do to make your app run? what language is it in? it is a WinForm app isn't it? what happens when you run your app by double-clicking its exe (in bin/debug/ or in bin/release/ subfolders)?
BTW: within the app, i.e. assuming your app has focus, it is the Shown event you want, not a timer!
|
|
|
|
|
I am compiling and executing with CTRL F5 it is a standard windows form in C#. I will have to look into executing outside the compiler.
TNX Luc
|
|
|
|
|
I don't know how useful this may be, as I'm a total newbie to C#, but I'm working tonight on the exact same situation - a form creating a form - and mine's working perfectly. The only difference I see is that, rather than passing a value in the new statement, I'm initializing that value in a separate statement immediately after, ie:
Form2 dlg = new Form2();
dlg.temp = fname;
if(dlg.ShowDialog()==DialogResult.OK)
{ ...
This assumes that Form2 defines a public member temp, of course. I have no idea why it would make a difference, but it just might.
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
electriac wrote: Unfortunatly the new form will not receive input
What do you mean by this ? Do you have a textbox in your form that doesn't receive what you type on the keyboard as soon as the form is opened? You may have to set its TabIndex property to 0 and TabStop to true .
|
|
|
|
|
There is no TabIndex or TabStop as the form is receiving input from an IR controller as a keydown event.
|
|
|
|
|
I don't know if I fully understand your question. But in windows applications, only the active control with the keyboard focus can receive keyboard events. You need to set focus to the textbox (or whatever your control is) before you can send keystrokes to the control.
|
|
|
|
|
Update:
I have done some more experimenting and find the following. When the program is executed outside the compiler the child Form2 is created but the focus remains on Form1. When compiled with CTRL F5 the focus goes to the compiler.
Here is where Form2 is created: Form2=playMKV
Application.RemoveMessageFilter(this);
if (temp.EndsWith(".mkv")) // its a Matroska file
{
playMKV dlg = new playMKV(fname);
//if (dlg.ShowDialog() == DialogResult.OK) // not necessary as there will always be a result 1 or 0;
dlg.ShowDialog();
if (dlg.Number == 1)
{
string temp2 = "\x22" + fname + "\x22";
System.Diagnostics.Process proc =
System.Diagnostics.Process.Start("mplayerc.exe", temp2 + " /fullscreen /play /close ");
proc.WaitForExit();
}
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
Application.AddMessageFilter(this);
return;
}
I have tried delaying the this.Focus in Form2 as Luc suggested and it seems to make no difference.
private void timer1_Tick(object sender, EventArgs e)
{
timer1.Enabled = false;
this.Focus();
this.Activate();
this.BringToFront();
}
This Form2 closes on any keydown event there being two options:
1.the "Enter" key is hit or "Enter" is pressed on the IRcontroller in which case the key event is == 13 returning 1 to Form1
or
2.on any other key the Form2 is closed returning 0;
Form2 keydownevent
if (keyEvent.KeyValue == 13)
{
num = 1;
}
else
{
num = 0;
}
this.Close();
The program works without problem as long as I click on Form2 with the mouse.
|
|
|
|
|
Shameel
TNX for your input as it allowed me to solve the problem. I added an event handler to the listBox on Form2 and the focus was gained by the form.
TNX again.
|
|
|
|
|
Is there a reason you use Application.RemoveMessageFilter(this) ?
|
|
|
|
|
Yes. The message filter seems to stop the Form2 from receiving the IR commands. Although I have not test without it since implementing the newest changes.
|
|
|
|
|
I checked and the keydown event goes to the parent form and not the child unless the Message Filter is removed.
|
|
|
|
|
Hi
Do you know, if there exist a code (application), that capture all the text from the keyboard? Application should not be seen, so it should run in tray, like a hiden application, but it still capture all the text.
If you don't konw if that kind of application exists, maybe you have some suggestions how to made it.
Thnx
|
|
|
|
|
Write a global keyboard hook - here's[^] one example.
/ravi
|
|
|
|
|
such apps are evil.
|
|
|
|
|
Yeah, it's called a keylogger and NO we're not going to tell you how to write one.
|
|
|
|
|
Hi
I have a gridview that get it's data from a dataset;
I add a checkbox to this gridview as culumn;
now my user can choose each row;
How can i recognize that checkboxes that have checked by user and other value of that checked rows?
|
|
|
|