|
by the way, does it do the samething in managed c++ 2005
|
|
|
|
|
Hi,
I'm trying to get all the paths of the open applications in a C# program.
What I need is only paths of open windows(the ones the "Task Manager" shows under his "Applications" Tab),i.e. the windows that are shown in the Taskbar.
For example if there is only 1 Word file open, named "1.doc", I need it's full path. (for example : "D:/Temp/1.doc").
Thanks, Gal.
|
|
|
|
|
So what you're asking is to get the full path of opened documents, not the paths of applications.
For starters, you can get the running processes (which includes applications) using the System.Diagnostics.Process.GetProcesses() method.
But from there you're on your own. There's nothing built into the framework (nor the Win32 API, AFAIK) that will let you see which document is opened by a program, simply because there is no way of letting Windows know when an application has a document opened. Windows does know when a file is opened, so you might be able to find some Win32 APIs that you could query to find the opened documents of the system.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Little House on the Flickr
Judah Himango
|
|
|
|
|
Hi,
I do need open documents but also open programs, which I opened (i.e. if the Visual .NET is open, I need the path to it's .exe file also)- all open windows(windows of documents and programs).
You said windows does know when a file is open.
I looked in the System and Environment objects but didn't find anything yet. From the process list I couldn't get anything usefull.
Do you know where windows keeps it? what Objects besides the 2 I mentioned might keep that kind of information?
Maybe the Task Manager keeps it since in his application tab it does shows exactly the open windows, though I couldn't find any API related to the Task Manager, nor files with that information that the Task Manager manages.
Thanks,
Gal.
|
|
|
|
|
Task Manager sees Processes, not open documents. The only reason TaskManager sees those is because the application treats each open document as a seperate process.
There is no API function anywhere that will tell you the open documents of any application. That has to be exposed by each individual app, and even that isn't done consistantly. This means you'll have to write code for every different app out there (Good Luck!) to enumerate their open documents.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi all,
I am using RSACryptoServiceProvider and RSAPKCS1SignatureFormatter to create private/public keys and signed data with the private key (later decrypt using public key).
i know how to get teh Module and Exponent inorder to send and use it later.
but i also want to get the private key so i can use it many times more.
now i use this code:
byte[] mod=RSA.ExportParameters(true).Modulus;
byte[] exp=RSA.ExportParameters(true).Exponent;
RSAParameters RSAKeyInfo= new RSAParameters(); //create new keyinfo
RSAKeyInfo.Modulus=mod; //set the modulus
RSAKeyInfo.Exponent=exp; //set the exponent
and later i creat new key and import the modulus and exponent.
it is working fine for the public key but if i want to Sign again using that key , i get an exception saying that the new key do not contain the Priavte key.
what can i do? how can i get hold of the Public key?
Thanks alot,
Ran.
R.Z
|
|
|
|
|
I intend to make a dictionary application. My problem is how to make my owner data file. My data file is too big. How can i can read it quickly at any position in file, what's the structure in file. Can you so some information involve my problem. Thank a lot
|
|
|
|
|
I guess you could make an index file that keeps track of where in the file each entry is.
The structure of the file?? That's entirely up to you. Start with what you're putting in this file, laying out the fields for what you're storing.
If you don't know this already, you're going to have a very hard time writing this app. I'd start writing sample applications that test writing, indexing, and reading your file. Do the research first to teach you what you need to know, then write the app.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi,
is there an AutoSave example to automagically safe a file at certain interval in time?
I tried use the Timer event but the problem is to tackle when the save-destination-time is due/passed.
I would like to skip looking into windows services as that would make it just 'too much' )
Thanks.
|
|
|
|
|
Run a separate thread in the background
Thread thd = new Thread(new ThreadStart(autoSave));
thd.Start();
private void autoSave() {
Thread.Sleep(20000);
}
WM.
What about weapons of mass-construction?
|
|
|
|
|
Thanx Willem, that is short and just what it should do )
|
|
|
|
|
Something that you have to consider, though: Using a separate thread to save the data means that you have to make sure that the operations on the data is thread safe, e.g. that you don't save the data in the middle of an update, and don't update in the middle of a save.
---
b { font-weight: normal; }
|
|
|
|
|
Yes, got that covered. Making a copy in memory of what i want to save first.
Thanks.
|
|
|
|
|
Any tips on repeating the thread eg. every 10 minutes?
|
|
|
|
|
Yep, add a while(true) construction around the code in the autoSave method
WM.
What about weapons of mass-construction?
|
|
|
|
|
You can easily solve that problem by locking the data you are saving:
private boolean enableAutoSave = true;
private Thread autoSaveThread = new Thread(new ThreadStart(autoSave));
autoSaveThread.start();
void autoSave() {
while(enableAutoSave) {
Thread.Sleep(10 * 3600000);
lock(data) {
save(data);
}
}
}
WM.
What about weapons of mass-construction?
|
|
|
|
|
Thanks Willem !
Works perfect !
I assumed that a While there would 'hog' the system/application, but no problem there
|
|
|
|
|
pxp wrote: Making a copy in memory of what i want to save first.
That doesn't solve the problem, it just somewhat decreases the risk for data corruption. The only difference between saving the data and copying the data is the amount of time it takes. You still have to lock the data while copying it.
---
b { font-weight: normal; }
|
|
|
|
|
I get my data from a class collection and print them to a textfile.
I should lock the class-collection before i save the data,...ok,..not thought about that...is that correct?
|
|
|
|
|
Yes, that would work.
Note, though, that if the main thread is trying to access the data while it's locked, it will freeze up until the save is complete.
---
b { font-weight: normal; }
|
|
|
|
|
Hello even i wanna save my controls value on the page every 30 sec auto save.So i just tried the code which you mentioned
LoadData()
{
Thread thd = new Thread(new ThreadStart(autoSave));
thd.Start();
}
private void autoSave()
{
Response.Write(System.DateTime.Now);
Thread.Sleep(10000);
LoadData();
//Wait 20 seconds //TODO: Handle autosave functionality
}
but the second time it throws error saying response in not available in the context ??
|
|
|
|
|
Hi all,
i have some trouble with XML file reading.
My logic:
<br />
XmlWriter myXmlWriter = new XmlTextWriter(_filename, System.Text.Encoding.UTF8);<br />
myXmlWriter.WriteElementString( "Version", "example string" );<br />
...etc...<br />
<br />
XmlDocument myXmlDocument = XmlDocument();<br />
myXmlDocument.Load(_filename);<br />
...<br />
string strVersion = myXmlNode["Version"].InnerText;<br />
When opening a xml file i get the following error: "There is no Unicode byte order mark. Cannot switch to Unicode."
What i would like to achieve is a simple XML save/load for some values i wanna retrieve at runtime.
My suggestion without the use of Encoding:
<br />
TextWriter tw = new StreamWriter(_filename);<br />
XmlWriter myXmlWriter = new XmlTextWriter(tw);<br />
I could be getting the problem becuase the xml file was manually edited at one time using Notepad.
My question(s):
Can (or may) i skip the "System.Text.Encoding" ?
And if so, what are the downsides of it ?
Thanks in advance,
Jan
|
|
|
|
|
You can skip the encoding in the call that creates the stream, but that doesn't mean that it's not using any encoding. It will be using the default encoding, which is UTF-8.
---
b { font-weight: normal; }
|
|
|
|
|
Thanks Guffa.
I had a problem with: "There is no Unicode byte order mark. Cannot switch to Unicode." but don't know what tha cause of it is...
My goal is to have a 'bulletproof' xml reader/writer.
|
|
|
|
|
Hi, im looking at some Java code and im assuming that the synchronized keyword is pretty similar to the lock keyword in C#? Anyone able to confirm that?
In addition I think this code is replicating some of the .NET System.Threading.Monitor class, but again I am unsure. How would I replicate this code with the use of lock keyword and Monitor class?
This is some example Java of what im looking at. What is the equiv of the .notify() method below in the .NET Monitor Class? Im pretty sure .wait() is erm... Wait()
private Object unsafeLoaderMonitor = new Object();<br />
public void DoSomething()<br />
{<br />
synchronized (unsafeLoaderMonitor) <br />
{<br />
unsafeLoaderMonitor.notify();<br />
}<br />
}<br />
<br />
public void DoSomethingElse()<br />
{<br />
synchronised(unsafeLoaderMonitor)<br />
{<br />
unsafeLoadMonitor.Wait(100000);<br />
}<br />
}
|
|
|
|