|
In my VB.net application I want to make sure that only one instance of application is running at a time on a client computer. Furthermore I want to perform following tasks:
1. My application should accept a command line argument (Customer Id).
2. Pass this argument to already running instance of the application.
3. Search and load customer data from database and display the respected form in the existing instance.
I have managed to restrict multiple instance by using Process object and easily accepted command line arguments by using My.Application.CommandLineArgs collection.
Public Sub Main()
Dim tempProcess As Process
tempProcess = checkInstance() ' A function which validates current process
If tempProcess Is Nothing Then
Application.Run(New frmWelcome)
Else
Dim hwnd As Int32
hwnd = tempProcess.MainWindowHandle.ToInt32
Try
If hwnd > 0 Then
If IsWindowVisible(hwnd) = False Then
ShowWindowAsync(hwnd, ShowWindowConstants.SW_MAXIMIZE)
End If
SwitchToThisWindow(hwnd, True)
SetForegroundWindow(hwnd)
SetActiveWindow(hwnd)
LoadContact() 'A function which extracts command line argument and call a function from existing running instance.
Application.Exit()
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End If
End Sub
When I call a function from existing instance I get an error 'Unable to create window handle'.
Basically I am not an experienced VB.Net programmer, I will appreciate if someone have a look into it and help me out. I will be very thankful if someone pass me an example.
Many thanks
Nas
|
|
|
|
|
Isn't this a copy of a previous post[^]? And were possible solutions not given in this thread[^]>
Perhaps you need to consider an alternative approach to resolving your issue?
Steve Jowett
-------------------------
Sometimes a man who deserves to be looked down upon because he is a fool, is only despised only because he is an 'I.T. Consultant'
|
|
|
|
|
Yes it was the copy of my previous post. In my last thread I have been asked to search on MSMQ but during search I found out .Net Remoting is also a possible solution. My development level is not upto standard that I could decide what technology should be used and how exactly to tailor it to meet the requirement. I just need initial guidance.
Many thanks
|
|
|
|
|
I think, from what you have said previously, that Remoting is NOT what you require as you are only interested in the application already running on the local PC, therefore MSMQ is most likely to be the simplest solution.
There are some very good kick start guides to MSMQ on the web.
Steve Jowett
-------------------------
Sometimes a man who deserves to be looked down upon because he is a fool, is only despised only because he is an 'I.T. Consultant'
|
|
|
|
|
Just an after-throught :-
To check that the program is the first instance, try this code :-
'Check to see if already running<br />
Dim currentProcess As Process = Process.GetCurrentProcess()<br />
Dim allProcesses() As Process = Process.GetProcessesByName(currentProcess.ProcessName)<br />
<br />
If allProcesses.Length > 1 Then<br />
'already running<br />
Else<br />
'not already running<br />
End If
You could also pass the necessary parameter via a file. For instance write an file somewhere, containing the necessary parameters and use a FileSystemWatcher to monitor the file for changes.
Depands how slick you want it, but the simplest options are usually the best.
Steve Jowett
-------------------------
Sometimes a man who deserves to be looked down upon because he is a fool, is only despised only because he is an 'I.T. Consultant'
|
|
|
|
|
Many thanks Steve, I am looking into MSMQ and your idea of writing a file seems solving the problem.
Nas
|
|
|
|
|
In my label i want to display hh:mm:ss
this i want to show continuously on my web form .
i am developing web based application.
Please help me how i can do this through the java script.....
|
|
|
|
|
This is a VB forum not a JavaScript. Try posting in the Web Development forum.
Steve Jowett
-------------------------
Sometimes a man who deserves to be looked down upon because he is a fool, is only despised only because he is an 'I.T. Consultant'
|
|
|
|
|
Hello!
I am developing a drawing application using VB2005. I draw my objects on drawing area, work with it ... and finally on SAVE i write all the properties of drawing object to dataset and write its XML file to save on local drive.
If for drawing something i create a pen:
Dim myNewPen As New Pen(CType(panBoxColor.BackColor, Color))<br />
currentCont.setMyColor = myNewPen<br />
how can i store that 'Pen' to Dataset Table so that when i write to XML it could be saved and when i reopen that XML file VIA dataset, i could redraw my control by initializing its properties from Dataset Table ?
Thanks for any help.
colgateas900197
|
|
|
|
|
You can't save the Pen object itself. Store the information needed to recreate the Pen object.
Experience is the sum of all the mistakes you have done.
|
|
|
|
|
Hi all,
I've a problem in ListView management. The problem is the following:
when the ListView looses the focus, the currently selected item in the
ListView looses the selection: the selection in the ListView is not mantained
switching from a control to another in the user interface.
How can I solve this problem ? I'd like to let the ListView to mantain
the selection.
Thanks a lot !
|
|
|
|
|
Create a variable that stores the selection in the listview at the moment it gets made or changed. As an added bonus it is also easier to clean up if you have to, for example due to another choice made elsewhere on your form.
My advice is free, and you may get what you paid for.
|
|
|
|
|
Hi guys an gals,
I have a form using databinding to a dataset. Whenever the user navigates to another record I check if datasource.HasChanges is true, and if so I ask whether the user wants to save changes. All this works perfect on my pc, but on the users' pcs it basically asks to save on EVERY navigate and even form load, even though there were NO changes made.
Here is the code snippet:
Private Sub OrganisationBindingSource_CurrentChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles OrganisationBindingSource.CurrentChanged<br />
Try<br />
If Me.OrganisationBindingSource.DataSource.HasChanges = True Then<br />
If (MessageBox.Show("Record has changed. Save changes?", "Save", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) = Windows.Forms.DialogResult.Yes) Then<br />
Me.OrganisationBindingSource.EndEdit()<br />
Me.SoftwareBindingSource.EndEdit()<br />
Me.ContactBindingSource.EndEdit()<br />
Me.QuoteBindingSource.EndEdit()<br />
Me.OrganisationTableAdapter.Update(Me.CRMDataSet.Organisation)<br />
Me.SoftwareTableAdapter.Update(Me.CRMDataSet.Software)<br />
Me.ContactTableAdapter.Update(Me.CRMDataSet.Contact)<br />
Me.QuoteTableAdapter.Update(Me.CRMDataSet.Quote)<br />
Else<br />
Try<br />
Me.OrganisationBindingSource.CancelEdit()<br />
Me.SoftwareBindingSource.CancelEdit()<br />
Me.ContactBindingSource.CancelEdit()<br />
Me.QuoteBindingSource.CancelEdit()<br />
Me.OrganisationBindingSource.DataSource.RejectChanges()<br />
Catch<br />
End Try<br />
End If<br />
End If<br />
Catch err As Exception<br />
MessageBox.Show(err.ToString.Replace("'", ""))<br />
DH.RunQuery("INSERT INTO Log_Error (Message, Process) VALUES ('" & err.ToString.Replace("'", "") & "', '" & Me.Name & "')")<br />
End Try<br />
End Sub
Any ideas on what could cause this? As I say, this does not happen on my pc, so I dont know how to debug it???
Thanks in advance
Ed
|
|
|
|
|
Hi Ed,
This code snippet shows the code that gets executed when the user navigates. You say that this code gets executed at the wrong time (also). So it seems to me that you're looking in the wrong place. If you debug this it will always run correctly, and apparently also on the other pc. You will have to look at the code that precedes the navigation event. Somewhere a piece of code is triggering the event or allowing some user action or background process, which your pc does not allow, either by configuration or because of some program that is running on either pc.
Good luck,
Johan
My advice is free, and you may get what you paid for.
|
|
|
|
|
Hi to all
Please tell me how i will handle this code in vb.net
the code is there in vb and i am converting that into .net
<br />
Dim oFSO As New FileSystemObject<br />
If oFSO.FolderExists("C:\recordedFiles") = False Then oFSO.CreateFolder ("C:\recordedFiles")<br />
If oFSO.FolderExists("C:\recordedFiles\TataAig") = False Then oFSO.CreateFolder ("C:\recordedFiles\TataAig")<br />
<br />
Filename = agent_login_Name & ApplicationNumber & "_" & Format(Now, "YYYYMMDD_HHmmss") & ".Wav"<br />
filePath = "c:\RecordedFiles\TataAig\" & Filename<br />
<br />
Shell App.Path & "\Harddisk.exe -preset " & Chr(34) & App.Path & "\LameCfg.hdp" & Chr(34) & " -record -output " & Chr(34) & filePath & Chr(34) & " -minimize"<br />
<br />
g_FL_Recording_Started = True<br />
lblRecordingStatus = "ON"<br />
cmd_Start.Enabled = False<br />
cmd_stop.Enabled = True<br />
Call log_error("Start Recording ")<br />
|
|
|
|
|
Look at the System.IO.File and System.IO.Directory namespaces where you will find things like
System.IO.Directory.Exists(myFolder)
and
System.IO.Directory.Create(myFolder)
Steve Jowett
-------------------------
Sometimes a man who deserves to be looked down upon because he is a fool, is only despised only because he is an 'I.T. Consultant'
|
|
|
|
|
hi all ,
How to get the MAC address
Is there any need to create a new class??
please explain me in detail with coding.
i vl be thankful to u .
regards,
saravan
|
|
|
|
|
I'm not 100% on this, but I'm pretty sure you can do this through WMI.
"Every time Lotus Notes starts up, somewhere a puppy, a kitten, a lamb, and a baby seal are killed.
Lotus Notes is a conspiracy by the forces of Satan to drive us over the brink into madness. The CRC-32 for each file in the installation includes the numbers 666." Gary Wheeler
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Coo
|
|
|
|
|
Your should try Googling your question[^]before you post them here.
Steve Jowett
-------------------------
Sometimes a man who deserves to be looked down upon because he is a fool, is only despised only because he is an 'I.T. Consultant'
|
|
|
|
|
Thanks Steve, that was brilliant.
|
|
|
|
|
In my Application VB.Net and I am going to cerate combo box,
It is behavior like a windows O.S using run command.
Combo Box is having some data many rows,
If user type “c” it is come listed “c” order word
Franics K Antony
|
|
|
|
|
Check out the articles for the autocomplete comboboxes.
"Every time Lotus Notes starts up, somewhere a puppy, a kitten, a lamb, and a baby seal are killed.
Lotus Notes is a conspiracy by the forces of Satan to drive us over the brink into madness. The CRC-32 for each file in the installation includes the numbers 666." Gary Wheeler
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Coo
|
|
|
|
|
Hi ,
i want this 'Datatype' property as combobox in propertygrid .
-- Datatype
-- Date (Sub Property)
-- Text (sub Property)
-- Number (sub Property)
--Format -
On selecting type of sub-property in combobox the things should be appear in next property ' Format '
if Date is selected ,' dd-mm-yyyy ' should appear .
If Text is selected , nothing should appear.
if NUmber is selected,' 12345 ' should appear in Format property .
Vb8.0
|
|
|
|
|
Try this format
dd-MMM-yyyy
Franics K Antony
|
|
|
|
|
Try setting your Property DataType as an Enum. For example :-
Enum DataTypes<br />
Date=1<br />
Text=2<br />
Number=3<br />
End Enum<br />
<br />
Property DataType As DataTypes<br />
Get<br />
'Your code here<br />
End Get<br />
Set(ByVal Value As DataTypes)<br />
'Your code here<br />
End Set
Steve Jowett
-------------------------
Sometimes a man who deserves to be looked down upon because he is a fool, is only despised only because he is an 'I.T. Consultant'
|
|
|
|