|
Why would you want to prevent 2 calculators from being opened? Or two of anything? At any given time I have a good 7 or 8 notepad's open.
|
|
|
|
|
Member 4250705 wrote: Hi experts,
I'm not sure anyone here would want to lay claim to being an 'expert'.
ex - signifies a has been
spert - well a spurt is a drip under pressure.
You might want to try "Hi oh exalted gurus."
Much better.
Henry Minute
If you open a can of worms, any viable solution *MUST* involve a larger can.
|
|
|
|
|
Member 4250705 wrote: Hi experts,
I prefer, "Your Eminence" myself, but, whatever...
Member 4250705 wrote: Now,my problem is when I run the process the second time, it opens a new exe
OK, so keep the process in a class global variable and check to see if it's Nothing and check to see if it's HasExited property is True before you try to launch another copy.
Also, to maximize the window of another process, you have to send the MESSAGE to the app's window. You can get the window handle to send the message to from the Process class's MainWindowHandle property. Then you just have to call the Win32 API function SendMessage with the window handle and the message. You can get a code example on SendMessage from PInvoke.net[^].
The two constants for the WM_SYSCOMMAND and SM_MAXIMIZE message are:
Private Const WM_SYSCOMMAND As Integer = 274
Private Const SC_MAXIMIZE = 61488
Private myProcess As Process = Nothing
...
If myProcess Is Nothing OrElse myProcess.HasExited Then
myProcess = New Process()
myProcess.StartInfo.Filename = "calc"
myProcess.Start
Else
''' This is where you would send the message to the main window
''' to maximize the window.
End If
You'll have to do some more work to account for the case of the Process exiting, but this should be enough to get you started.
|
|
|
|
|
Thanks a lot for your advice
|
|
|
|
|
thanks a lot...
Could u please tell me how to send a message to maximize to the main window...
Else
''' This is where you would send the message to the main window
''' to maximize the window.
Thanks
I am a learner Always
|
|
|
|
|
Well, it's not really a message as it is a function call to send one. You need the main window handle property of the process you lanuched, then you use that to call ShowWindow[^].
|
|
|
|
|
Hi to All ,
Could anyone help me please , how to take a back up for Ms Access database using vb.net coding...
Note that I am doing this from same application which is using the database. I think it shouldn't give a problem since during taking the backup I am not doing anything else with the database.
Thanks in advance
|
|
|
|
|
An ms access database is just a file so in order to back it up you can just copy the file.
The system.io.file namespace can help you with that.
|
|
|
|
|
You can simply copy the file, but if it is in use at the same time, there's a slight risk that the copy isn't consistent.
You can also use DBEngine.CompactDatabase Method[^] via Microsoft Access Object Library (add reference to it). The starting point is Access.Application[^] object which you can create using COM interop.
|
|
|
|
|
Image processing
I am working on a Vb.net 2005 Express application where I need to compare the color of a image with the reference colors.
What I am planing to do is
- take some pixels from the image
- compare them with the reference colors
- do it for more then one pixels from a area of picture
- decide weather the shade is light or dark
Is this the right approach and how do I do some thing like this ?
The other things I need to know
I am interested in finding the shade of the color so the the user can get a output some thing like light, dark or medium ... how do I find that the given color is in which gradient range of that shade
Regards
Nishkarsh
|
|
|
|
|
nishkarsh_k wrote: Is this the right approach
That depends on what you want to accomplish...
nishkarsh_k wrote: how do I do some thing like this ?
Load the image into a Bitmap object and use the GetPixel method.
nishkarsh_k wrote: I am interested in finding the shade of the color so the the user can get a output some thing like light, dark or medium ... how do I find that the given color is in which gradient range of that shade
Look at the GetBrightness method of the Color class.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
So I have to do some code in VBA (if only it was .Net I wouldnt be here!) to get a list of all the groups a COMPUTER object is in from Active Directory. I can do this easily with ADS and a user, but the IADsComputer object does not have groups with it. Any idea how I could do this? The following works for users (in Excel)
Sub testHarness()
'Dont forget to add reference to Active DS Type Library
Dim usr As ActiveDs.IADsUser
Set usr = GetObject("WinNT://<domainname>/<username>,user")
For Each oGroupIn usr.Groups()
ActiveCell.Value = oGroup.Name
ActiveCell.Offset(1, 0).Select
Next
End Sub
I would think that the following would work for Computers, but alas it does not . I have been hunting for examples all day, but I can only find .net ones (which all work perfectly!)
Sub testHarness()
'Dont forget to add reference to Active DS Type Library
Dim srv As ActiveDs.IADsComputer
Set srv = GetObject("WinNT://<domainname>/<servername>,computer")
For Each oGroup In srv.Groups()
ActiveCell.Value = oGroup.Name
ActiveCell.Offset(1, 0).Select
Next
End Sub
Or do I need to do this completly differently?
(And I really hope this is the right forum for VBA, I couldnt see anything else)
modified on Tuesday, January 13, 2009 7:05 PM
|
|
|
|
|
I have found the answer, based on this post - http://www.tek-tips.com/viewthread.cfm?qid=1245332&page=1[^]
My resulting code now looks like this, in case anyone else is interested:
Sub TestHarness
Set objTrans = CreateObject("NameTranslate")
objTrans.Set 3, "<domainname>\<servername>$"
strComputerDN = objTrans.Get(1)
Set objComputer = GetObject("LDAP://" & strComputerDN)
colGroups = objComputer.MemberOf
For i = 0 To UBound(colGroups)
ActiveCell.Value = GetGroup(colGroups(i))
ActiveCell.Offset(1, 0).Select
Next
End Sub
Function GetGroup(strGroup) As String
z = Split(strGroup, ",")
If Left(z(0), 3) = "CN=" Then
GetGroup = Right(z(0), Len(z(0)) - 3)
Else
GetGroup = ""
End If
End Function
|
|
|
|
|
Hi,
Actually i am creating some graphic using SYSTEM.DRAWING namespace in vb.net now every thing is going fine but i Want o make that file as read only means no body can change it in either paint or any else tool.This can be achieved by
System.IO.File.SetAttributes("c:\test.jpg", IO.FileAttributes.ReadOnly)
but doing this way user can change the attribute of file using file properties in windows Xp. I Need help to make the file readonly for ever can any body help me please..
|
|
|
|
|
You shouldn't and probably can't do this. A user owns the machine, or his privileges are set by an administrator that control this. Your application cannot and should not be able to do what you want for obvious reasons...
|
|
|
|
|
sarfarazaliqureshi wrote: I Need help to make the file readonly for ever can any body help me please..
Can't be done. Someone, most notably, an admin, will ALWAYS be able to revert it back to read/write, for any user.
|
|
|
|
|
Embed the image in a protectable document, like PDF or Word, and sign the document. Whilst it doesn't prevent copying, it does prevent other people from making alterations and publishing them under your name. If they alter it, the sign "breaks".
See cacert.org if you want a key.
I are troll
|
|
|
|
|
Hi, i am creating a Winforms UserControl that has a splitcontainer and a couple of labels and textboxes, in the left panel of the splitcontainer are the lables and the textboxes in the right panel, What i want is to be able to change the spliter distance in desing time with the mouse, not changing the property.
all i get now when i drag my usercontrol in a new form is a static picture of my control, and i can't interact with it's contents in any way.
How could i do that?
Thanks in advance
|
|
|
|
|
I'm having a problem figuring out how to programatically activate a second form in a multi-form application using the primary form to activate it. The problem is that I have code set to run when the second form is loaded which I did move to the activated sub but the code did not run. To activate the second form I used the Code Form2.Activate() . Is this code incorrect or am I missing something or am I completely misunderstanding the usage of this sub? I have found another way to successfully start the second form, however, it is by using
Form2.Visible = True<br />
Form2.Visible = False . And this poses a security problem because I do not want the second form to be accessible if a section of the code goes awry. Thanks for you help.
modified 8-Sep-21 21:01pm.
|
|
|
|
|
Activate gives also gives the focus to a form, so it'll immediately spring up so the user can click in and use the form.
You cannot activate a form without showing it first. Activate gives the focus to a visible form, but does nothing if the form is not already visible.
I don't understand what the design problem is or why you're trying to achieve this.
|
|
|
|
|
Hi i'm trying to update a specific table in access by executing an append query.The code i'm using to do so is the following:
Dim SqlCmd As Command
Set SqlCmd = New Command
SqlCmd.CommandType = adCmdText
SqlCmd.ActiveConnection = MyCnn
SqlCmd.CommandText = "Execute CRegSubAdicNulo"
Set RecSet = SqlCmd.Execute(, , adExecuteNoRecords)
As far as i can see i don't see anything wrong,the problem is after executing that piece of code the table doesn't have anychanges
What am i doing wrong?
Thanks in advance!
|
|
|
|
|
Calferreira wrote: SqlCmd.ActiveConnection = MyCnn
Where are you instantiating the connection? (= New Connection)
I are troll
|
|
|
|
|
When the form loads a make a new instance from the connection:
Set Mycnn=New Connection
Mycnn.open blablabla
This 'CRegSubAdicNulo' is an append query made inside access that checks for records and inserts them into a table that will be edited to fill the empty columns.
|
|
|
|
|
Is there any error? What is inside MyCnn? Did you see if the connection is active first, are you able to read and write in other areas of your application?
|
|
|
|
|
I get no error the application runs fine,after executing this code i posted i can use the application normally getting data from the database with no problems.
|
|
|
|