|
Sounds like you don't want a Service at all, how about a Windows Scheduled Task?
|
|
|
|
|
Thanks.
Ok, what i am looking for is like, when i am logging off, i had made my windows service to uninstall certain dlls. Once it is finished, it has get killed itself and get uninstalled, because, it should not do the uninstall for the next time logoff.
Thanks
Kumar
|
|
|
|
|
I've adapted other code i found on the internet to use postmessage instead of mouse_event i think it was: http://wolfsfiles.googlepages.com/MouseSimulatorPostMessage.cs[^]
So... my goal is to send mouse clicks to a window without bringing it into focus... that code does do the mouse clicks just fine but it automatically brings the window into focus. (if i use sendmessage it does the same behavior... also what's the difference between postmessage and postmessageA? :P)
So is their anything i can do to send the mouse click without bringing the window into focus.
|
|
|
|
|
FocusedWolf wrote: is their anything i can do to send the mouse click without bringing the window into focus.
I don't think so. Depending on what your higher goals are, there may be better ways to achieve them.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Hi,
I've made a kind of telnet class that has these methods:
+Connect()
+string Response() : Reads the stream
+string SendMessage() : Writes to the stream and calls response()
The problem is that if call response and there is no response, I get stuck..
I tried using networkStream.DataAvailable but still gets stuck,
algo tried making a
while (timespan.Seconds < timeout) {
..
}
But still.
For example if I conncet to a POP server, this could happend.
I say: RETR 2
1st line of response
I ask another line of response (calling Response())
2nd line of response
Repeat these last two lines until...
I ask another line of response
-here it gets stuck because there arent more lines-
|
|
|
|
|
Start a timer whenever you say something. If there's no response in 30 seconds, chances are that there won't be a response at all. In that case, you can give the user the option to either;
* keep waiting
* abort the waiting
Good luck
I are troll
|
|
|
|
|
Well I tried that but it stills get stuck,.. I think its stuck on the .ReadLine() and doesn't give the chance to continue with the while's condition (timespan.Seconds < timeout)
I think threading is needed here.. but in the background the .ReadLine() would still be stuck consuming CPU :/
public string Response()
{
if (!cl.Connected) { return null; }
timeoutCheck = DateTime.Now;
TimeSpan timespan = DateTime.Now - timeoutCheck;
while (timespan.Seconds < timeout)
{
if (ns.DataAvailable)
{
if (secure)
{
return secureReader.ReadLine();
}
else if (!secure)
{
return nsReader.ReadLine();
}
}
timespan = DateTime.Now - timeoutCheck;
}
return "timeout waiting response";
}
|
|
|
|
|
Quake2Player wrote: in the background the .ReadLine() would still be stuck consuming CPU
Blocking calls such as ReadLine() do not consume CPU cycles, the underlying input/output operations are event driven: when nothing happens, nothing gets processed. The only cost is memory, the thread that executes the call just sits there, with the memory associated to it (mainly its stack).
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Hi,
I am trying to read an xml file into a dataset and have been met with nothing but problems.
The xml file is in the following format:
<?xml version="1.0"?><br />
<Catalog xmlns:dt="dt"><br />
<Rec><br />
<ITEM dt:dt="string"></ITEM><br />
<QTY dt:dt="string">1</QTY><br />
<SUB dt:dt="string"></SUB><br />
<CATALOG dt:dt="string">ABC123</CATALOG><br />
</Rec><br />
</Catalog>
I have tried this code in C#:
<br />
Dataset ds = new DataSet("Test");<br />
ds.ReadXML(OFD.FileName);<br />
The touble is that all have in the Dataset is a table called "Rec" and one column called "Rec_Id", clearly this is not what I want!!
If I remove the dt:dt="String" datatypes then everything is fine.
I think this can be done by specifing a schema, but I do not know how you do this whilst reading into a dataset nor do I know enough about schemas to know what to specify where!!
Can anyone help?
Thanks
|
|
|
|
|
I cannot explain why you are having this problem, but I can tell you what is happening.
If you set a breakpoint in your code, immediately after the ds.ReadXML(OFD.FileName); and examine your members in the Autos window.
You will find that ds has had its name changed from "Test" to "Catalog", which it has obviously picked up from the xml file.
If you then expand the Tables node, then the list node you will see that you in fact have 5 tables
[0] Rec
[1] ITEM
[2] QTY
[3] SUB
[4] CATALOG
As I said above, I do not know why this happens, but you have already found the cure.
M_Aurelius wrote: If I remove the dt:dt="String"
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
A couple of things come to mind:
Do you own the form (implied by removing the dt:dt)
Why not create a table in a test program with the structure you want and write the dataset out, you then ahve the format to work with.
Failing that use xpath to traverse the xml and populate said table manually!
Failing that post it the the XML forum [^] to get a sensible answer
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Thanks for your replys guys.
The xml file is generated automatically by some software we use and I want as little manual intervention as possible so I shall try the xml forum (which I hadn't actually noticed ).
Failing that I shall indeed try xpath to see whether it works.
Cheers
|
|
|
|
|
Hi Friends,
I googled the whole night and I browsed MSDN the entire day, but I did not find any results because what I wanted to know, maybe was termed as unneccasary or malfunctioning. Actually, I want to replicate my Console Program to a particular destination with the user's complete knowledge and permission. But the thing is that, I want to do that programmatically (i.e. not by exiting the program an then Copying or pasting it).
Like this:
Console.WriteLine("Are you sure to copy this program to C:\Program Files\? Press 'Y' for confirmation or 'N' to exit and hit enter");<br />
if (Console.ReadLine()=="Y")<br />
{<br />
}<br />
else if(Console.ReadLine()=="N")<br />
{<br />
return;<br />
}
Please help me. And also tell me if I am clear.
Cheers,
Rajdeep.NET
|
|
|
|
|
You may or maynot be able to actually do this, while the program is running.
Couple thoughts come to mind:
1). The normal means: File.Copy[^]
2). CreateProcess to a batch file that copies the .EXE from local to wherever
3). Save the state of your console app, create process to external program and terminate. External program copies app and then starts it back up, restore console app state.
That's "off the cuff" ...
|
|
|
|
|
|
I've just tried it on the exe for the solution I'm working on and it worked fine.
System.IO.File.Copy(
@"C:\Users\Dave\Documents\Visual Studio 10\Projects\TestSolution\TestSolution\bin\Debug\TestSolution.exe",
@"C:\Users\Dave\Documents\Visual Studio 10\Projects\TestSolution\TestSolution\bin\Debug\TestSolution2.exe"); Obviously you should check if the file exists already and you have write permissions on the folder.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Hi Davey,
Thanks for replying! But the thing is that even if I assure this peice of code to my application, it would work fine for me but not in other's system (I mean client's machine). BTW not everyone gonna have Visual Studio installed and the file path will be different, ofcourse.
Like,
@"C:\Users\Dave\Documents\Visual Studio 10\Projects\TestSolution\TestSolution\bin\Debug\TestSolution.exe", will be the source file and @"C:\Users\Dave\Documents\Visual Studio 10\Projects\TestSolution\TestSolution\bin\Debug\TestSolution2.exe" is the destination where I'll be copying it. But, not any of my client are going to have the program installed in C:\Users\Dave\Documents\Visual Studio 10\Projects\TestSolution\TestSolution\bin\Debug\. Therefore, the program will be crash since it could not find the source to be copied.
Note: Is there some way like(Pseudo code) this:
System.IO.File.Copy("this.Executable", "destination");
where, 'this.executable' is the curent program, without defining its location (since the file path wont be same in every machine)
Please help me,
Cheers,
Rajdeep.NET
|
|
|
|
|
Rajdeep.NET wrote: But the thing is that even if I assure this peice of code to my application, it would work fine for me but not in other's system (I mean client's machine).
Yeah, so when the app launches under that user's ID, they better have the proper permissions to the next machine, or else the copy will fail.
|
|
|
|
|
string thisPath;
thisPath = System.Windows.Forms.Application.ExecutablePath;
thisPath = System.Reflection.Assembly.GetEntryAssembly().Location; then use thisPath as the source parameter for the Copy method.
BTW, you didn't mention that this was your problem in your original question. This[^] would have helped you solve this in a few seconds. You said you had searched before asking here - if that's true, then you need to read this[^]. I don't mean this in a condecending way, it's a very good article (94 '5 votes' can't be wrong).
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Hi Davey,
Yeah maybe I wasn't that describable in my question, but you got it correctly. Thanks! Now, I think that maybe I will need the Thread.Sleep method such that the program keeps running but with a certain interval in order to get the executable file path and then generating a batch file which will copy the executable to the destination directory. This is great. But ain't it a little difficult with .NET? I mean like, I have seen programs which replicate (termed as 'Malwares') but do they really use this type of complex programming logic for this purpose?
Cheers,
Rajdeep.NET!
|
|
|
|
|
I sincerely hope you're not writing anything 'nasty'. The path will not change while the program is running so this is a one time check, you can store the result in a static variable if needed.
Instead of sleeping, better to use a Timer and run the File.Copy when needed in a Tick or Elapsed event handler (depending on what type of Timer you use). If the Copy takes longer than the Interval of the Timer you will run into serious problems so set that property very carefuly and include some checking.
Why do you need to do this by the way? Before offering you any more help, I'd like to be sure of your intentions.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Rajdeep.NET wrote: I googled the whole night and I browsed MSDN the entire day, but I did not find any results
You searched all day and night and couldn't find the File.Copy[^] method? Even when it is the FIRST result on google when you search for 'copy file c#'! (proof[^])
My failometer is detecting vast quantities of FAIL!
"Its SQL - hardly programming..." (Caslen)
|
|
|
|
|
Nothing like that, I did found File.Copy() method long days back. But this method can only be implemented whenever we know what file we are going to copy and to where. But maybe you have not been though by question properly. I want replication of my program right out of its execution.
Let me know if I need to be more clear,
Cheers,
Rajdeep.NET
|
|
|
|
|
Rajdeep.NET wrote: But this method can only be implemented whenever we know what file we are going to copy and to where.
Not true. All you have to ro is create the folder path you need.
|
|
|
|
|
It is easy to find out where the executing file is stored! System.Reflection.Assembly.GetExecutingAssembly().Location was one of the first results for it! You can then get the filename from that string and then use it in the destination string (eg. @"C:\Deistination\" + filename), it's really very simple, you're just making a big deal out of it.
My failometer is detecting vast quantities of FAIL!
"Its SQL - hardly programming..." (Caslen)
|
|
|
|