|
To start a process (e.g. Notepad) you could say something like:
using System.Diagnostics;<br />
.<br />
.<br />
.<br />
<br />
Process myProcess = new Process();<br />
myProcess.StartInfo.FileName = "Notepad";<br />
myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Maximized;<br />
myProcess.Start();
Regards,
Polis
Can you practice what you teach?
|
|
|
|
|
hi guys,
can anyone tell me how i candetect a net connection and then lauch an application. It would also be great if someone could tell me how i can stop the application when the net connection is disconnected.
Plz guys, no lame stuff like using timers!
|
|
|
|
|
What do you mean by "detecting a net connection"? Are you talking about a connection request coming in from the outside or an outbound connection request? Are you talking about ANY type of connection, like NetWare, NetBIOS, TCP, UDP, ..., or are you just looking at IP traffic only?
There's nothing that will detect all connection traffic and notify you. In order to get something like this to work, you'd probably have to implement a type of firewall to do something like this.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
no...what i meant was like ICQ. When ICQ detects an internet connection, it launches the messenger automatically. I want to make something similar. How can i detect an internet connection
|
|
|
|
|
there are two ways to implement that, the easy way, and the hard way which is i dont know how to do it but i know that u can do it,
ok the easy way is to use i timer that raises an event every 1 seconds for example,
when it fires the event, ping any website do u want, lets say www.codeproject.com, if u got an aknowledgement, then the internet connection is established otherwise, there is no connection
now the HARD way, there is a win32 dll which raises an event whenever the connection is established, u have to import that DLL and hook ur function with it.
actually, it is easier than doing the first way, but if u didnt find the name of that DLL to import it or if u dont have a background about programming win32 API then u have to use the first way
|
|
|
|
|
Have a look here[^]
Regards,
Polis
Can you practice what you teach?
|
|
|
|
|
this is it man, the boolean function returns true or false, now all u have to do is to call this function every period of time using a timer, if it returns true, //do something, else //do something else
I'll send u the code by email or ill post it on codeproject.com
|
|
|
|
|
I sent the code to ur gmail account
|
|
|
|
|
My gmail account? Cause I haven't received anything
Regards,
Polis
Can you practice what you teach?
|
|
|
|
|
dude whats ur gmail account, i got failure notice when i sent it to ur gmail
|
|
|
|
|
polis.pilavas@gmail.com
Regards,
Polis
Can you practice what you teach?
|
|
|
|
|
dude thats not working, give me any other email address for u
|
|
|
|
|
Is there a faster way to give a specific color in a richTextBox?
void makeThisRed(int start, int length)<br />
{<br />
richTextBox1.Select(start,length);<br />
richTextBox1.SelectionColor= Color.Red;<br />
}
|
|
|
|
|
Nope. That's the fastest way to do it...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
It is too slow for large richTextBoxes.
Maybe using pointers or something else?
|
|
|
|
|
It can't be done using pointers...
All RTF formatting is done in-line with the text, kind of like HTML tags. In order for you to change a section of text to a different format, the RTF stream holding all the text and formating information must be rewritten. This means copying everything from the beginning of the RTF stream to the point where you are making your changes, appending the new formatting codes to the copy, append the segment of text you're changing, appending any closing formatting codes that are required, then, finally, appending the remaining original RTF stream.
You can't do it using pointers because you have to rewrite the entire RTF stream anyway so it's in one contiguous stream of data.
It sounds like, because of performance considerations, that an RTF box wasn't a good choice to fulfill your requirements.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
|
|
I'm having a strange issue with the Connect() function on the Socket object.
I have a .Net "ActiveX" user control (not sure if you can still call it that) on a web page that connects to a remote machine (or in the case of testing, localhost). I have set permissions so I can use sockets through the web control, so it actually does connect.
When I launch the Connect() event, it instantly connects to the server, as my server's BeginAccept callback is fired. However, the client continues to "hang" or "block" for about a minute before continuing.
Additionally, I can send data from the server to the client with no problems, and once the client stops hanging, it receives the data through a NetworkStream object.
My question is this: Why is it hanging even after connecting? I have *never* had this issue before. If I use it outside of a .NET "ActiveX" user control, it works instantly and the connection does not hang. Is this an issue specific to .NET ActiveX controls? And if so, is there a workaround?
I would also like to mention that if I use BeginConnect instead of Connect and attach a callback, the callback function is not called for another minute as well, even though the connection to the server was made instantly.
I am at a loss as to what could be causing this, but clearly a timeout of 1 minute to connect is unacceptable for my application.
MSDN articles and Google have yet to yield a result. I am hoping that someone here could shed some light on this issue.
Thank you very much.
- Sam B.
EDIT - At this time I'm contemplating switching to UDP. If anyone thinks that's a better idea, let me know. Although, I'd like to keep TCP for all it's worth :P
|
|
|
|
|
Hi
I have a singleton class/component created in C#. It job is to send construct mail object using the input xml and send email using SMTP. It has a public function Execute(xmlData string, out string returnStatus) which does all that.
xmlData has tags like From, TO, Subject, Body, Priority etc.
returnStatus is used to return the status to the caller (success or exception message).
My question is: if there are multiple (for example 50) calls to Execute() function to construct and send emails, then is it thread safe? If not, how can I do that?
Please advice. Thanks in advance.
Pankaj
|
|
|
|
|
Does the function use shared data? Shared data includes member variables, static members of the current and other classes etc.. If not, your function is thread safe.
Because each thread has its own stack, as long as you use only local variables and the parameters*, your function should be thread safe.
*Beware of reference parameters though, it is possible that some other thread might change the object after passing it to your function.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Hi all,
does anybody know what the default ApartmentState of a C# application is, if you do not set the [STAthread] attribute for your main method?
I have read different statements in the Internet. Some say that the default ApartmentState for a C# application is "ApartmentState.MTA", whereas for VB.NET it's "ApartmentState.STA".
Others say that the default state is "ApartmentState.Unknown".
Well, I tried it out myself using a simple C# app, but what I found was not really good:
Almost every computer had "ApartmentState.Unknown" as default, but unfortunately some had "ApartmentState.MTA".
What influences this behavior?
The reason why I'm asking is because I have an application which uses CoInitlizeSecurity and DragAndDrop.
The app starts like this:
public static int Main(string[] args)
{
System.Threading.Thread.CurrentThread.ApartmentState = ApartmentState.STA;
int nHresult = CoInitializeSecurity(IntPtr.Zero, -1, IntPtr.Zero, IntPtr.Zero, RPC_C_AUTHN_LEVEL_NONE, RPC_C_IMP_LEVEL_IMPERSONATE, IntPtr.Zero, 0, IntPtr.Zero);
...
}
This almost ever works. But on some computers that have MTA as default ApartmentState, I cannot reset the CurrentThread's ApartmentState to STA, because this can be set only once. The consequence is that "Drag and Drop Registration" fails, because Drag and Drop requires STA.
When I put the [STAThread] attribute to my main method, then the CurrentThread's ApartmentState is STA on every computer, but CoInitializeSecurity returns RPC_E_TOO_LATE.
Now is there something that I can do to solve this problem?
thanks in advance for your help!
-------------------------------------------
The light at the end of the tunnel has been switched off temporarily due to budget problems...
|
|
|
|
|
I haven't dealt with this problem myself, but this[^] article might help you out a little.
John
"You said a whole sentence with no words in it, and I understood you!" -- my wife as she cries about slowly becoming a geek.
|
|
|
|
|
All
I have an application which loads a large amount of data into a combobox, ~1000 entries.
Before my machine got updated with .NET CLR 1.0 SP3 the dialog with the combobox was displayed an immediately ready for use. Now with SP3 the dialog is locked out for ~2 seconds.
Using Compuware Dev Partner Performance Analysis the population of the combobox is the culprit.
The code access security permissions are being invoked and taking an inordinate amount of time on the Combobox.AddRange.
By denying the various permissions the UIPermission was identified as being invoked as follows.
System.Security.Permissions.UIPermission, mscorlib, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 failed.
at System.Security.SecurityRuntime.FrameDescHelper(FrameSecurityDescriptor secDesc, IPermission demand, PermissionToken permToken)
at System.Security.CodeAccessSecurityEngine.Check(PermissionToken permToken, CodeAccessPermission demand, StackCrawlMark& stackMark, Int32 checkFrames, Int32
unrestrictedOverride)
at System.Security.CodeAccessSecurityEngine.Check(CodeAccessPermission cap, StackCrawlMark& stackMark)
at System.Security.CodeAccessPermission.Demand()
at System.Windows.Forms.Control.FromHandle(IntPtr handle)
at DevExpress.XtraBars.MessageFilter.BarManagerMessageFilter.InternalPreFilterMessage(BarManager manager, Int32 Msg, IntPtr HWnd, IntPtr WParam, IntPtr
LParam)
at DevExpress.XtraBars.MessageFilter.BarManagerMessageFilter.DevExpress.Utils.Win.Hook.IHookController.InternalPreFilterMessage(Int32 Msg, IntPtr HWnd, IntPtr
WParam, IntPtr LParam)
at DevExpress.Utils.Win.Hook.HookManager.InternalPreFilterMessage(Int32 Msg, IntPtr HWnd, IntPtr WParam, IntPtr LParam)
at DevExpress.Utils.Win.Hook.HookManager.WndHook(Int32 ncode, IntPtr wParam, IntPtr lParam)
at System.Windows.Forms.SafeNativeMethods.GetWindowTextLength(IntPtr hWnd)
at System.Windows.Forms.Control.get_WindowText()
at System.Windows.Forms.ComboBox.NativeClear()
at System.Windows.Forms.ObjectCollection.ClearInternal()
at System.Windows.Forms.ObjectCollection.Clear()
However asserting the permission as follows did not resolve the issue,
[UIPermissionAttribute(SecurityAction.Assert, Unrestricted=true, Window=UIPermissionWindow.AllWindows)]
Has anyone else encountered this change in security behaviour, and know of any configuration change that can remedy the performance penalty now being incurred?
Regards
David
Hasta La Victoria Siempre!
|
|
|
|
|
Hi...
I have a richtextbox whit readonly enabled, but the user must type at the keyboard anyway, but when they do, there comes a beep from the copmuter! is there a way to disable that sound? (the sound also come when you press 'Enter' in a textbox)
Thanks...
QzRz
QzRz
|
|
|
|
|