|
gareth111 wrote: The only thing i do with the DateTimes after creating them is to do a ToString().
If you're passing the values to an SQL command you would do well to use Parmeters of type DateTime.
|
|
|
|
|
<node label="Holiday Destinations" pic="imgs/homepage.jpg" attached="0" text="ny" />;
if xml file is in this format then how can i get a lable name as a "holiday destinations on tree node?
if xml is in the form < text> themn tex will be a lable of tree node.in this format.
how can i get it?
|
|
|
|
|
Using method
System.Diagnostics.Process.GetProcessesByName(processescname)
, my program will not work anymore once someone has changed their name.
is there any way to solve this problem?
Thanks for advandce
|
|
|
|
|
With this amount of information, there's no way to solve the problem.
If you try to identify a process by its name and the name is changed there's no way of knowing if it's still the same program.
Why do you need to know whether a process with a given name exists?
Wouldn't it be better to use a mutex to flag the active state of an application?
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
How can someone change a process name?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
by changing the EXE's file name (while it is not running).
Probably relevant only if two programs need to communicate or synchronize something;
a uniquely named resource (mutex) is the way to go. Process names are bad: someone can create
a totally different app, give it the same file name in another folder, so it would get the
same process name.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Luc Pattyn wrote: by changing the EXE's file name (while it is not running).
Well, a process, you know, is a running executable , hence my question.
Luc Pattyn wrote: Probably relevant only if two programs need to communicate or synchronize something;
a uniquely named resource (mutex) is the way to go.
Provided the above scenarion holds (I doubt about, but I'm a malicious guy), also a registered window message may do the trick.
Luc Pattyn wrote: Process names are bad
Please be kind on (process) names. Last time someone found user-friendly names bad, he founded an incomprehensible technology full of funny 128 bit identifiers, fancy abstract classes and obscure registry entries.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
Most of us have a first name, a last name, and when it really matters a unique and
rather long identification number, such as a social security number.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
thank all
Just consider this code:
<br />
System.Diagnostics.Process[] myProcesses = System.Diagnostics.Process.GetProcessesByName(procname);<br />
if (myProcesses.Length == 0)<br />
Console.WriteLine("Nothing.");<br />
else<br />
Console.WriteLine("Is running.");<br />
Process's name can be changed easily, just like Luc Patyn said. Process's ID changes each time process begin to run in our system.
Just wonder can I get it by what?
|
|
|
|
|
Seems like you have two apps and are asking about interprocess communication. Then please
start by telling more abbout the situation:
- what is it all about?
- how did the target app start? can you modify its code if need be?
- what it is your controlling app wants to do to that process? any particular requirements,
as to speed, resources used, reentrancy, ...?
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
thanks
all is about I want to check whether one process is running or not.
My check was not correct if someone renamed the EXE file which uses to open that process.
So I decide to check it out by comparing size of main module of each process are running and size the EXE file:
<br />
using System;<br />
using System.Diagnostics;<br />
using System.IO;<br />
<br />
...<br />
<br />
public Process[] getProcessesByExeSize()<br />
{<br />
Process[] myProcesses = null;<br />
int i = -1;<br />
Process[] allproc = Process.GetProcesses();<br />
foreach (Process p in allproc)<br />
{<br />
string s = p.MainModule.FileName;
FileInfo finfo = new FileInfo(s);
long fileinbytes = finfo.Length;<br />
if (fileinbytes == 12345)
{<br />
myProcesses[i+1] = p;<br />
i++;<br />
} <br />
}<br />
return myProcesses;<br />
}<br />
I tried to replace "\" by "\\" or add @ in front of s but not success.
modified on Thursday, January 31, 2008 11:21:03 PM
|
|
|
|
|
Hi,
1.
sorry for the delay, CodeProject e-mail notification is slow (again).
2.
you failed to answer my questions so what follows may not fit well with what you intend to do.
3.
when I develop two apps myself, one needing to check the other, I use a uniquely named mutex;
that works quickly and reliably, without causing all the GetProcesses and FileInfo overhead,
which may fail anyway for one of several reasons:
- you may not be allowed to see other user's processes;
- the other EXE size may change (because you modify it if it is your code, or you or
Windows Update or some other updater decides to update it, if it is not your code)
it certainly is a good approach for implementing a "single instance of application".
4.
your C# code seems a bit troubled:
- myProcesses[i+1] = p; will fail if you don't create the array first; and
then you don't know its exact size beforehand, so you would be better of using either
an ArrayList or a List< string>
- don't see why your index should start at -1 and [i+1] is used
- don't understand what the \ and \\ and @ comment is about, there are no literal paths
in the code as far as I can tell.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
hello,
Using DShowNET,I want to preview live video, capture it to a video file and grab frames at the same time and here i am encountering problem.Using the ISampleGrabberCB interface, one can preview the video and grab frames without any problems. Using the ICaptureGraphBuilder2 interface,one can preview and capture video to a file without any problems. But how to do both these tasks at the same time?
I m adding each filter one at a time and then connecting them one at a time. The result; a problem in GetConnectedMediaType method.
media = new AMMediaType();
hr = sampGrabber.GetConnectedMediaType(media);
It is returning negative value(-214...) and i dont get y? :'(
Can anybody who worked in DShowNet help me out?
B!z
|
|
|
|
|
This forum is for general C# questions. If you want help with obscure 3rd party products, I suggest you contact their technical support.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
Dear forumners,
I have an issuse with Response.Contenttype for word document and excel sheet, where on the both cases aspx page gets reloaded twice and then the Session, Cookies and Authentication tickets are lost. For pdf and txt files it works fine. Because of this i could not authenticate whether the User who is trying to view the document file is authenticated or not.
This issues is been listed microsoft support under the link
http://support.microsoft.com/kb/185978[^]
but there is no exact solution for this issue. Please help with this.
Thanks and regards,
john aneston
regards,
john aneston
modified on Thursday, January 31, 2008 5:22:45 AM
|
|
|
|
|
hi,
i have access a xml file in tree view, now i want to do ..........
when i will click on any node on the tree view the all attributes of that tree node like ,pic, sound, text etc should be seen in another textbox(multiline). i have used trewview for this...
how can i do this?
|
|
|
|
|
Hi,
We need to create an email with two voting buttons (Voting buttons are std feature in Microsoft Exchange email) from a C# program.
Please let us know if any body knows how to do this or if we can get some sample code somewhere.
Thanks in advance
SB RS
|
|
|
|
|
From a quick google. Perhaps this thread[^] might help you?
|
|
|
|
|
Dear all,
my company is asking me to go for a certification, can u guys please advice me which certification(C# or VC++) ll be good for me for future.i worked on both technology..
Thanks in advance....
vikas da
|
|
|
|
|
This forum is for C# programming questions.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
hi, i am a vb.net user and i want to try to convert my vb.net program to C#.Net. i have a class (clsDataAccess) where i execute my query. i'd try it to convert it to C#.Net but it gives me a lot of errors. i want to use this clsDataAccess as my default class when executing my query. can you pls help me to convert it. below is my code.
Imports System<br />
Imports System.Data<br />
Imports System.Data.SqlClient<br />
Imports AddressBook.usermod1<br />
<br />
Public Class clsDataAccess<br />
<br />
Public objConnection As SqlConnection<br />
Public objTransaction As SqlTransaction<br />
<br />
Public Function SqlConnect() As Boolean<br />
<br />
Try<br />
objConnection = New SqlConnection<br />
'objConnection.ConnectionString = "Server=(local);database=AddressBook;user id=sa;password=;"<br />
objConnection.ConnectionString = "Server=" & GetServer("\conn.cfg") & "; DataBase=" & GetDatabase("\conn.cfg") & "; User ID =" & GetUser("\conn.cfg") & "; Integrated Security=false"<br />
<br />
If objConnection.State = ConnectionState.Closed Then _<br />
objConnection.Open()<br />
<br />
Return True<br />
<br />
Catch ex As Exception<br />
<br />
MsgBox("Failed to connect to data source.", MsgBoxStyle.Information, "")<br />
Return False<br />
<br />
Finally<br />
objConnection.Close()<br />
<br />
End Try<br />
<br />
End Function<br />
<br />
Public Function ExecuteQuery(ByVal strSQL As String) As DataTable<br />
Dim objDataTable As DataTable<br />
Dim objDataAdapter As SqlDataAdapter<br />
<br />
Try<br />
<br />
SqlConnect()<br />
objDataAdapter = New SqlDataAdapter<br />
<br />
With objDataAdapter<br />
<br />
objDataTable = New DataTable<br />
.SelectCommand() = New SqlCommand(strSQL, objConnection, objTransaction)<br />
.Fill(objDataTable)<br />
<br />
Return objDataTable<br />
<br />
End With<br />
<br />
Catch sqlex As Exception<br />
Throw sqlex<br />
<br />
Catch ex As Runtime.InteropServices.COMException<br />
Throw ex<br />
Finally<br />
objDataAdapter = Nothing<br />
<br />
End Try<br />
End Function<br />
<br />
Public Sub ExecuteNonQuery(ByVal strSQL As String)<br />
Dim objSqlCommand As SqlCommand<br />
<br />
Try<br />
SqlConnect()<br />
objSqlCommand = New SqlCommand(strSQL, objConnection)<br />
objSqlCommand.Connection.Open()<br />
objSqlCommand.ExecuteNonQuery()<br />
<br />
Catch ex As SqlException<br />
Throw ex<br />
<br />
Catch ex As Runtime.InteropServices.COMException<br />
Throw ex<br />
<br />
Finally<br />
objSqlCommand = Nothing<br />
<br />
End Try<br />
End Sub<br />
<br />
Public Function ExecuteNonQuery(ByVal strSQL As String, ByVal sqlparams As SqlParameter()) As Boolean<br />
<br />
Try<br />
Dim intindex As Integer<br />
Dim objsqlcommand As New SqlCommand(strSQL, objConnection, objTransaction)<br />
<br />
For intindex = 0 To UBound(sqlparams)<br />
objsqlcommand.Parameters.Add(sqlparams(intindex))<br />
Next<br />
<br />
objsqlcommand.ExecuteNonQuery()<br />
Return True<br />
<br />
Catch ex As Exception<br />
<br />
Throw ex<br />
<br />
End Try<br />
End Function<br />
End Class
Thank You.
Don't block the drive way of all the newbies in programming.
|
|
|
|
|
looks like ur trying to convert a VB class to C#
hope that link helps you
Convert VB .NET to C#[^]
Rocky
Success is a ladder which you can't climb with your hands in your pockets.
|
|
|
|
|
This seems lazy to me. I would have thought it would be a good introduction to C#, converting existing code.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
I have a BenQ x700 Pro keyboard and I installed Windows Vista. Unfortunetly BenQ does not want to make software for my model. It has specialty keys such as: Volume Control, Mute, Standby, My Media (loads Windows Media Player), Next Track, Previous track, Play/Pause and Stop just to name a few. Is it possible to catch these specialy keys? If so do you have any suggestions how to do this?
[Edit]
The program has to be able to catch keys wether or not it has focus.
[/Edit]
Thanks.
modified on Wednesday, January 30, 2008 4:29:19 PM
|
|
|
|