|
Why don't you click on the link in my first reply and read up on it.
|
|
|
|
|
Hi, I would like to know how to detect whether adobe acrobate reader is installed my computer by using the code in vb 2005?
Thank in advance
|
|
|
|
|
You either look for the AcroRd32.exe somewhere under Program Files or you can look in the Registry under HKEY_LOCAL_MACHINE\SOFTWARE\Adobe\Acrobat Reader\version . Look for version number keys, or you can even look a little deeper for the Path value under the Installer key under each version key you find.
|
|
|
|
|
Dave Kreskowiak wrote: You either look for the AcroRd32.exe somewhere under Program Files or you can look in the Registry under HKEY_LOCAL_MACHINE\SOFTWARE\Adobe\Acrobat Reader\version
In my opinion, looking in registry is better. But if acrobate reader is not install it mean the registry should be like this: HKEY_LOCAL_MACHINE\SOFTWARE\Adobe or HKEY_LOCAL_MACHINE\SOFTWARE\ ? If so then i will write my code to detect the path in the registry and determine whether acrobat is install or not.
Thank you very much for your reply
|
|
|
|
|
I have to develop a weigh bridge software.
I am able to read data in Hyper terminal.
But the problem is that i have to get the weight in text Box.
thank you,
sri.
|
|
|
|
|
.NET offers the SerialPort class, and CodeProject holds several articles about it.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Hi All,
Long story short: I have a program that writes data to a database, and it will be corrupted if a person logs off during this process.
My question:
How do I handle the WM_QUERYENDSESSION in VB.Net to cancel the Windows Log Off?
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
If m.Msg = WM_QUERYENDSESSION Then
'Return sometime to say no log off
End If
MyBase.WndProc(m)
End Sub
Thanks =)
|
|
|
|
|
You're going overboard here. All you have to do is handle the Closing event of your startup form and set the eventArgs Cancel property to True.
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
If e.CloseReason = CloseReason.WindowsShutDown Then
e.Cancel = True
End If
End Sub
|
|
|
|
|
Is that for .NET 2003? I cant find FormClosingEventArgs under System.Windows.Forms
|
|
|
|
|
Yep, that's 2005. 2003 has something similar, but the event name is different and you don't get a ClosingReason property. You have to write the code to track if there is a database operation going on, then just deny closing the form if there is a transaction in progress.
|
|
|
|
|
Thanks for your responses, youve been very helpful.
However I am still encountering an issue. Windows keeps showing a messagebox to End Task because my program is taking too long, when a person clicks Shutdown or Log Off. I need the program to completely cancel Windows Log off, and not have this error show up.
Thanks in advance
|
|
|
|
|
Where's my head at?? After waking up, you can handle the SystemEvents.SessionEnding[^] event to do this. It's still a cancelable event.
|
|
|
|
|
Im sorry, your dealing with an idiot =(. No idea how to go about that
EDIT: I tried the example on MSDN.
It still brings up that "End Program" box even if I cancel the event, saying that my app has taken too long. That cant happen.
-- modified at 12:56 Tuesday 16th October, 2007
|
|
|
|
|
You have to wire up the event yourself.
Imports Microsoft.Win32
.
.
.
Private Sub Form1_Load(blah, blah) Handles MyBase.Load
AddHandler SystemEvents.SessionEnding, AddressOf MySessionEndingEventHandler
End Sub
Private Sub MySessionEndingEventHandler(ByVal sender As Object, ByVal e As SessionEndingEventArgs)
If TransactionPending Then
e.Cancel = True
End If
End Sub
TransactionPending is a variable that you set somewhere to notify this code that a database update is still going on somewhere.
The reason that code exists in the link I gave you is because your code must unhook this event before your form closes! (RemoveHandler SystemEvents.SessionEnding, AddressOf...) You would normally put this code in the form's Closing event. The problem is that there is no guaranteed order of the SessionEnding and Form.Closing events! The FormClosing event could fire first, unhooking the SessionEnding event handler, then the SessionEnding event could fire.
|
|
|
|
|
You've been extremely helpful, and I thank you for your patience with me =)
I will give the code a run and let you know.
|
|
|
|
|
Dave Kreskowiak wrote: The FormClosing event could fire first, unhooking the SessionEnding event handler, then the SessionEnding event could fire.
One simple solution to this is have the SessionClosing event be static to the class. The class could simply maintain a static variable that indicates if it's ok to shut down, which the instance class can set to true/false (and of course you can get as complex here as you like, including other variables to explain what's going on, etc.).
Then, the handler can be wired and unwired in the main application code where Application.Run is called, instead of needing to do it inside the form. This way, you don't need to worry about the form's lifetime, only your application's.
"If you think of yourselves as helpless and ineffectual, it is certain that you will create a despotic government to be your master. The wise despot, therefore, maintains among his subjects a popular sense that they are helpless and ineffectual."
- Frank Herbert
|
|
|
|
|
And you can go back to the original requirement and scrap all this SessionEnding crap and maintain database consistency with transactions. So what if Windows shuts down before the app is done?? What if the power fails??
|
|
|
|
|
Dave Kreskowiak wrote: And you can go back to the original requirement and scrap all this SessionEnding crap and maintain database consistency with transactions. So what if Windows shuts down before the app is done?? What if the power fails??
... What are you on about? You seem to be upset about something and I'm not sure what you're actually saying/asking here.
"If you think of yourselves as helpless and ineffectual, it is certain that you will create a despotic government to be your master. The wise despot, therefore, maintains among his subjects a popular sense that they are helpless and ineffectual."
- Frank Herbert
|
|
|
|
|
Patrick Sears wrote: ... What are you on about? You seem to be upset about something and I'm not sure what you're actually saying/asking here.
No, it's just another situation I thought of at the very last minute. My brain has been fried all day...
|
|
|
|
|
Dave Kreskowiak wrote: No, it's just another situation I thought of at the very last minute. My brain has been fried all day...
No problem.. I know the feeling. I've been battling a stupid databinding problem all day..
"If you think of yourselves as helpless and ineffectual, it is certain that you will create a despotic government to be your master. The wise despot, therefore, maintains among his subjects a popular sense that they are helpless and ineffectual."
- Frank Herbert
|
|
|
|
|
Well, the code worked. Thank you!
However, I found what was causing me mass frustration. The code works perfect in XP (which is the platform I need it for), but on Vista, it always brings up that End Task box. Apparently MSDN says Microsoft added that on purpose for Vista...
I hate Vista.
Thanks for all your help
|
|
|
|
|
Is it possible to copy the data in a DataGridView column into an array without using a loop? I was hoping that there was, and that it might be perhaps faster than a loop.
Thanks in advance
|
|
|
|
|
cstrader232 wrote: Is it possible to copy the data in a DataGridView column into an array without using a loop?
No. You have no choice but to enumerate the cells you need from wherever the data is being kept and copy them to any array.
|
|
|
|
|
I have to execute an application (ie: c:\applications\task1.exe). I have to send some different commands and wait for the responses. Some responses are fast and has only few lines, some will take long time to execute but response every second with a dot until it completed
I would line to send command line through VB environment (might be with Shell (...) command?), but able to capture the responses without waiting it completed (to monitor its processes)
Anyone can show me how to do it?
Many thanks
|
|
|
|
|
There's a bunch of code behind that. But, you're launching the process with the Process class, then redirecting the StandardInput and StandardOutput streams so your code can capture the output of the console app.
I don't have an example handy because I'm walking out the door right now...
|
|
|
|