|
Luc Pattyn wrote: - on app start, get explorer process ID.
It's not unusual for me to have multiple instances of explorer.exe running. Unless I can determine which one is drawing the taskbar/systray, a list of explorer.exe process IDs wouldn't tell me much
Luc Pattyn wrote: - periodically check it, and on a change, remove your NotifyIcon, then add a new one.
Yeah...the whole reason I inquired about a notification message is that I'd rather avoid polling...seems like such a waste.
Luc Pattyn wrote: Are you sure this is worth it?
Well, if my app is minimized, the only way you can interact with it is through its tray icon...so, if it disappears, pretty much the only thing you can do is kill it in Task Manager and restart it...
Luc Pattyn wrote: FYI: I wrote an article on stray tray icons once. You could use those techniques to check the presence of (exactly) one NotifyIcon for your app.
Thanks, I'll check it out.
|
|
|
|
|
Not sure about the rest, but unless something changed in Vista/Weven, explorer.exe seems to only run one process, no matter how many instances you have up.
|
|
|
|
|
Ummm...no. I can have multiple instances of explorer.exe showing up in Task Manager, in the Processes tab, each with its own process ID. That's always been the case as far as I can remember.
|
|
|
|
|
Hmm, ok, your system works differently than mine... When I open a new windows explorer, or even do a Start, Run, explorer.exe, it puts it all in the same process.
|
|
|
|
|
Now that I think of it, this is probably due to the fact that I always check the "launch folder windows in a new process" option (Tools, Folder Options).
|
|
|
|
|
hi,
i am trying to access data through named pipes. Data is written in the named pipe from a plugin(written in unmanaged C++);client pipe;. I wanted to make the whole application more easy to handle so I am trying to use C#;server pipe; to take in the data from the named pipe for further processing.
My problem is I can get the client and server connected, but the C# code has hard time reading the data from the named pipe. The c++ code writes the data in the named pipe in LPTSTR format.
the data is basically real-time data from a gaming application.
Any suggestions on how to make the data accessible from the c# code, or on using any other medium besides named pipes to communicate the data between the two application will be highly appreciated.
thanks
letiny
|
|
|
|
|
Are you saying you are putting unmanaged text pointers into the pipe?
if so I guess you will need some kind of Marshal.PtrToString method, something I hope will never happen to me. I tend to get all objects created by managed code, and then pass their pointers to the primitive side for production/consumption.
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.
|
|
|
|
|
the plugin uses WriteFile() function to write in the named pipe. The WriteFile() function takes in the data param in LPTSTR format.
i am using sr.ReadLine() method in the C# code where sr is as follows.
i.e.;
NamedPipeServerStream pipeServer = new new NamedPipeServerStream(.....);
StreamReader sr = new StreamReader(pipeServer);
sr.ReadLine();
|
|
|
|
|
P.S.
I have already tried Marshal but could not find an option. I tried it again, when i use Marshal.PtrToStringUni(sr.ReadLine()), it gives me an error:
-->Error 2 The best overloaded method match for 'System.Runtime.InteropServices.Marshal.PtrToStringUni(System.IntPtr)' has some invalid arguments
-->Error 3 Argument '1': cannot convert from 'string' to 'System.IntPtr'
therefore I am guessing it is not a pointer.
The LPTSTR format is defined as zero-terminated string of TCHAR (TCHAR*) here[^]
|
|
|
|
|
Have you tried reading the bytes manually? ReadLine() returns a string, but Read() with a byte buffer might give you more to work with...
Chances are, if that works, you're going to see one of two things in the buffer:
1) A lot of data = Probably your raw data. You might have to strip out a trailing zero, then do an Encoding.ASCII.GetString()
2) Only a few bytes... That's your pointer... Extract the right number of bytes (4 for a 32-bit system, 8 for a 64-bit - Can probably get that from the framework)... Turn it into an IntPtr and try marshalling it (Or is that unmarshalling?)
Either way, get the data in a buffer so you know what you're dealing with.
|
|
|
|
|
Exactly, look at the raw data, and try and recognize it.
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.
|
|
|
|
|
This looks promising
I will definitely try this and let you know.
Thank you all of you guys for your suggestions!!
|
|
|
|
|
by this I meant the idea of using the Read() with a byte buffer.
Thanks again.
|
|
|
|
|
|
I have already gone through these articles you send me.
I was successfully able to create named pipe in c# both client and server and run them.
I was also able to do the same with visual C++ code.
The game plugin is written in visual c++, it outputs some real-time game data that I need. I have written named pipe client in visual c++ within the plugin which writes the data to the named pipe.
My problem is I have to process these data a lot for my final output, so it would make my life easier if I could access them through c# code. So I have programmed the server in C#
I can connect the client and server but c# code is not understanding the data which is in LPTSTR format visual c++ uses (well at least that is my guess). I guessed this because I wrote a server in visual c++ which could successfully access the data from the plugin.
Do you have any suggestions???
letiny
|
|
|
|
|
akhanal wrote: c# code is not understanding the data which is in LPTSTR
I had to do something fairly similar recently. What I did was I wrote a managed C++ dll that reads the data from the named pipe, converts the unmanaged strings to managed strings and then passes the managed strings on to the C# code.
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Individuality is fine, as long as we do it together - F. Burns
Help humanity, join the CodeProject grid computing team here
|
|
|
|
|
Hi all,
I'm trying to open a SQL Anywhere DB connection and setup a data reader with the data returned, only I keep getting the error:
'oConn.ServerVersion' threw an exception of type 'System.InvalidOperationException'
Here is my code:
string ConnString = "Data Source=***;UID=***;PWD=***";
SAConnection oConn = new SAConnection(ConnString);
oConn.Open();
string SQLStatement = "SELECT * FROM QAS.QAFISET WHERE MAINLVL='T' ORDER BY NAME";
SACommand command = new SACommand(SQLStatement, oConn);
SADataReader DRTest = command.ExecuteReader();
Any feedback would be greatful.
Thank you,
Mel
modified on Friday, July 24, 2009 2:25 PM
|
|
|
|
|
MelWheater wrote: string ConnString = "Data Source=xxx;UID=xxx;PWD=xxx";
There is porblem with your connection string. You didn't mention the Database name.
use this
string ConnString = "Data Source=ServerName;Initial catalog=Database;Name;UID=userid;PWD=password";
Hope this will help you
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
modified on Friday, July 24, 2009 2:41 PM
|
|
|
|
|
|
MelWheater wrote: Could you do me a give favor and remove the Data source UID and PWD from your message please. I forgot to take them out in my initial post
Done. I was also thinking about that when I saw you just changed it, but forgot . Now its done
yes, Let me know if you have any issue.
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
Thanks
I tried including the database name only I then receive an error from the second line:
SAConnection oConn = new SAConnection(ConnString);
The error reads:
Invalid connection string. Error parsing connection parameter string
Parameter name: connectionString
Do I have to supply the full path to the location of the database in the Data Source or would just the server name do? I've tried both but get the same error.
Mel
|
|
|
|
|
MelWheater wrote: The error reads:
Invalid connection string. Error parsing connection parameter string
Parameter name: connectionString
Did you tried with the solution I have provided to you ? Is that working ?
MelWheater wrote: Invalid connection string. Error parsing connection parameter string
Parameter name: connectionString
Error says that your connection string is not in proper format. please show us the connectiono string that you are using right now.
Note : Do not need to give servername, uid and password
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
Yes I'm using the Connection string that you suggested, which includes "Initial catalog" and that is the error I received (mentioned above).
The connection string:
string ConnString = "Data Source=SvrName;Initial catalog=DBName;UID=uid;PWD=pw";
|
|
|
|
|
Why you have deleted your post?
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
modified on Friday, July 24, 2009 2:57 PM
|
|
|
|
|
lol...because it wasn't relevant to the initial question.
|
|
|
|