|
you really want me to repeat what he said?
1. don't use lots of File.Move() without checking first that no conflicts (file overwrites) will result. Solution: add code to get a two-pass approach, first mimic the renames, and if all seem to be successful, then actually do them.
2+3. don't create a thread that doesn't do a thing. this.Invoke(X) causes X to run on the main thread. And don't abuse Application.DoEvents()
Solution: choose a different threading approach, e.g. use a BackgroundWorker, put the rename operation in its DoWork, and report progress using the ProgressChanged event.
|
|
|
|
|
|
you're welcome.
|
|
|
|
|
well done!
|
|
|
|
|
Hi all,
I need to call "Desktop Property" screen in C# but I do not know how to do this.
(Can I use process.start to do this?)
Pls help me to solve this problem.
Thanks in advance
|
|
|
|
|
This should do it:
Process p = new Process();
p.StartInfo.FileName = @"C:\WINDOWS\system32\rundll32.exe";
p.StartInfo.Arguments = "shell32.dll,Control_RunDLL desk.cpl,,3";
p.Start(); Of course you should compute the WinSys32 path instead of assuming the string shown in the code fragment. For other RUNDLL32 parameters, see this[^] link.
/ravi
|
|
|
|
|
Thanks so much, ravi.
Have a nice day
|
|
|
|
|
Try Process.Start(Desk.cpl);
|
|
|
|
|
Most control panels are easily accessible:
Process.Start("desk.cpl");
|
|
|
|
|
Is it possible to do this :
I wanna [C#]to automatically add some line of codes to any form that I add to my project ?
|
|
|
|
|
That depends on what you want to do, but probably not.
|
|
|
|
|
In VB6 I have seen this .
They done that with some add-in .
(I wanna to add some codes to my new form that adds to my project as defualt)
|
|
|
|
|
You need to be more specific.
|
|
|
|
|
|
jojoba2011 wrote: I wanna [C#]to automatically add some line of codes to any form that I add to my project ?
That's possible; if I read your question literally, then you'd want to modify a textfile. As the other posters suggest, it might be that you're looking for an automatically generated header.
If it's the latter that you want, it'll depend on the IDE. In SharpDevelop, you'd go to the "Tools" menu, pick "Options", go to the "Coding" node and edit your template. Visual Studio uses project- and itemtemplates that you can modify, but you could also opt to create a Macro.
I are Troll
|
|
|
|
|
Ah, I see. He might mean that, but it's hard to tell.
Or write your own base Form from which to derive -- I do that.
|
|
|
|
|
PIEBALDconsult wrote: He might mean that, but it's hard to tell.
Yup, just guessing, also based on the other posts'.
PIEBALDconsult wrote: Or write your own base Form from which to derive -- I do that.
You're right in stating that it's better to have a shared base than to copy a template - it makes updating/maintenance a lot easier. It might make sense to add those base-forms as item-templates to Visual Studio.
I are Troll
|
|
|
|
|
Yes, it is, by building a Visual Studio template. See this[^] chunky read.
/ravi
|
|
|
|
|
Hello there! I am "successfully" using WMI to get a list of products from any computer that can be accessed remotely. I understand that it only shows products that were installed using a MSI file.
What I would like is to list products installed (MSI, EXE, or whatever... not just MSI). Another thing I had to ask was if there was a better way to doing this? You might suggest reading the registry, but the problem is the computers that this application will run on is x86 and the servers are x64. So you can't read a x64 registry from a x86.
Does anyone have a better solution that will increase the speed and also show ALL products? I have read there really isn't a way to speed up WMI when getting a list of products.. just the way it is designed.
In case you want to see code:
public List<Product> InstalledApplications(string dns)
{
List<Product> products = new List<Product>();
try
{
ManagementScope scope = new ManagementScope(@"\\" + dns + @"\root\CIMV2", conn);
ManagementObjectSearcher mos = new ManagementObjectSearcher(scope, new ObjectQuery("SELECT Name, Vendor, InstallLocation, InstallDate2, Version FROM Win32_Product"));
foreach (ManagementObject mo in mos.Get())
{
if (mo["Name"] != null)
{
Product product = new Product();
product.Name = mo["Name"].ToString().Trim();
if (mo["Vendor"] != null)
product.Vendor = mo["Vendor"].ToString().Trim();
if (mo["InstallLocation"] != null)
product.InstallLocation = mo["InstallLocation"].ToString().Trim();
if (mo["InstallDate2"] != null)
product.InstallDate2 = ParseCIMDateTime(mo["InstallDate2"].ToString());
if (mo["Version"] != null)
product.Version = mo["Version"].ToString().Trim();
products.Add(product);
}
}
}
catch (ThreadAbortException) { }
catch (Exception ex) {
EventLog.WriteEntry("ADEM Application", ex.Message, EventLogEntryType.Error);
Product product = new Product();
product.Name = "Error";
product.Vendor = ex.Source;
product.InstallLocation = ex.ToString();
products.Add(product);
}
return products;
}
|
|
|
|
|
I don't
|
|
|
|
|
Jacob Dixon wrote: I understand that it only shows products that were installed using a MSI file.
It only shows those applications that have registered an "uninstaller" with Windows. Those applications can be found in the "Add/Remove applications" applet from your configuration panel.
Lots of older products don't register their uninstaller, or don't have one. Windows has no way of knowing that there's a new application on my computer if I plugin my USB-stick and launch FireFox-Portable.
Jacob Dixon wrote: Another thing I had to ask was if there was a better way to doing this? You might suggest reading the registry, but the problem is the computers that this application will run on is x86 and the servers are x64. So you can't read a x64 registry from a x86.
How about reading it on the system itself, and sending a XML-file with the results once your server requests a list of all installed apps?
I are Troll
|
|
|
|
|
Ahhh
So are you suggesting that I use WMI to create a process that reads it own registry key and sends me back the information?
|
|
|
|
|
Jacob Dixon wrote: So are you suggesting that I use WMI to create a process that reads it own registry key and sends me back the information?
Doesn't have to be WMI, you could also read the registry directly;
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall
If the application has an uninstaller, there will be an entry called "UninstallString", sometimes even an "QuitUninstallString".
..but yes, I was suggesting to create a local proces that does it's job (when the computer boots, or at the request of the server) and that sends the information. It would divide the task into two smaller subtasks; reading the information on a PC, and sending it to a server.
I are Troll
|
|
|
|
|
Uhm... but this was the first solution I tried before WMI. When reading the registry from a remote computer you will only get the applications that are the same processor type. Meaning you can only read x86 keys if you are on a x86 system. So a Windows XP x86 cannot read all the programs that were installed as x64.
Please correct me if I am wrong
|
|
|
|
|
Jacob Dixon wrote: When reading the registry from a remote computer
I was suggesting to read the registry (or use WMI) from the client-computer, using a small console application for example. Write the results to a file, and send it to the server
I are Troll
|
|
|
|