|
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
|
|
|
|
|
A bit of googling suggests that the driver itself handles the extra keys so the chances are Windows won't even see them as keystrokes without a working driver. Have you tried installing the XP drivers using XP compatability mode?
Failing that, this[^] page (BenQ Singapore) has a driver dated December 2007 so it may work with Vista. It's in .rar format so you'll need WinRar or something similar (there are free utilities available) to unzip it.
Good luck!
|
|
|
|
|
Yes I tried BenQ software for XP and it didn't work. It caught the actions but nothing happened as a result. IE I turned the volumn control knob on the keyboard but the volume didn't change.
I tried the site the Singapore site but it didn't work. Thanks anyways.
|
|
|
|
|
A global key hook should be able to catch the keys. A quick search revealed this[^].
You will be looking for the following values from the Keys[^] enumeration:
MediaNextTrack - The media next track key (Windows 2000 or later).
MediaPlayPause - The media play pause key (Windows 2000 or later).
MediaPreviousTrack - The media previous track key (Windows 2000 or later).
MediaStop - The media Stop key (Windows 2000 or later).
VolumeDown - The volume down key (Windows 2000 or later).
VolumeMute - The volume mute key (Windows 2000 or later).
VolumeUp - The volume up key (Windows 2000 or later).
Then you could use the MCI[^] API to forward the commands.
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
Regarding that code you pointed me too. After put each line of code on it's one physical line and after fixing a few problems I have one left to solve:
<br />
protected static extern IntPtr SetWindowsHookEx(HookType code, HookProc func, IntPtr hInstance, int threadID); <br />
Error #1:
The type or namespace name 'HookProc' could not be found (are you missing a using directive or an assembly reference?)
On a slightly related note. Can someone explain to me what:
[DllImport("user32.dll")]
does?
|
|
|
|
|
IIRC HookProc is a function pointer to the code that you want to have run everytime a key is pressed.
DllImport is used to make a native dll's functions available within a managed application.
Otherwise [Microsoft is] toast in the long term no matter how much money they've got. They would be already if the Linux community didn't have it's head so firmly up it's own command line buffer that it looks like taking 15 years to find the desktop.
-- Matthew Faithfull
|
|
|
|
|
[Starts Laughing Uncontrollably]
Even thought BenQ's software is not installed a majority of the specialty buttons work such as Media Player control, Volume control, and the nav forwards and backwards buttons.
Thanks for the help.
|
|
|
|
|
I have a Panel with the Docking code:
Panel.Dock = DockStyle.Left;
And I have another panel with the same code, but I can't get the other panel underneath the already docked Panel.
How can I solve this?
|
|
|
|
|
What do you mean underneath? Do you want the two panels to form a single column with one on top and one on bottom?
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
Yes, it keeps making different columns but I want them, one on top, one on bottom.
|
|
|
|
|
In that case you need to nest the panels.
The idea is you have your MainForm with a panel (say leftPanel) docked to the left. Now, you would add two panels to leftPanel. The first would be docked to the top and the second would be set to Fill.
If you want something that is user-customizable (like Visual Studio) then that's a different story. There are examples of this if this is what you are looking for.
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|