Sign in to follow this  
Followers 0
BigDod

Need help with Dll

22 posts in this topic

I am very new to this programming lark so please forgive any stupid questions I may ask. I have put together a script to control VNC but when I close it I can't delete the files automatically because vnchooks.dll is still in use. Is there any way I can make sure the dll is not in use before I close the program. The script does not remove the files, it is done by the self extractor program. My script is below, please do not laugh.

#include <GuiConstants.au3>


Opt("GUIOnEventMode", 1)
Opt("TrayIconHide", 1)

; GUI
GuiCreate("Remote Control", 200, 300)

GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")

; PIC
GuiCtrlCreatePic("logo.bmp",10,10, 180,181,$SS_SUNKEN)

; BUTTON
$Button1=GuiCtrlCreateButton("Connect", 10, 250, 80, 30)
$Button2=GuiCtrlCreateButton("Close", 110, 250, 80, 30)

GUICtrlSetOnEvent($Button1, "ConnectButton")
GUICtrlSetOnEvent($Button2, "CloseButton")

; TEXT
GuiCtrlCreateLabel("Tel :- **** ******[CODE] before Connect", 10, 210, 190, 30)
GUICtrlSetColor(-1,0xff0000)   ; Red

GUISetState(@SW_SHOW)

While 1
  Sleep(1000) ; Idle around
WEnd

Func CLOSEClicked()
      Run("winvnc.exe -kill")
      Sleep(2000)
       Exit
 EndFunc

Func ConnectButton()
    $remote_Station = INPUTBOX("Remote Control", "Remote Control Address", "", "", -1, 120)
    Run("winvnc.exe -connect " & $remote_station)
EndFunc

Func CloseButton()
       Run("winvnc.exe -kill")
       Sleep(2000)
         Exit
EndFunc


Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

You may want to look at the ProcessClose function and add it near the end of your CloseButton function

ProcessClose("notepad.exe")

$PID = ProcessExists("notepad.exe") ; Will return the PID or 0 if the process isn't found.

If $PID Then ProcessClose($PID)

Edited by Truffle

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

While 1

  Sleep(1000) ; Idle around

WEnd

sleep(1000) is 1 full second... I have found this to be to long in an idle.. maybe

sleep(100)

would work better

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

You may want to look at the ProcessClose function and add it near the end of your CloseButton function

<{POST_SNAPBACK}>

Thanks for you quick answer.

Run("winvnc.exe -kill") in the script is supposed to kill off the process and I added the sleep(2000) in case the program was exiting too fast for the dll to close. Can the ProcessClose function work with a dll even though it does not show in task manager



Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites

Can the ProcessClose function work with a dll even though it does not show in task manager

<{POST_SNAPBACK}>

Check this

; List all processes
$list = ProcessList()
for $i = 1 to $list[0][0]
  msgbox(0, $list[$i][0], $list[$i][1])
next

if it shows... then yes

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

Check this

; List all processes
$list = ProcessList()
for $i = 1 to $list[0][0]
  msgbox(0, $list[$i][0], $list[$i][1])
next

if it shows... then yes

8)

<{POST_SNAPBACK}>

Thanks but it does not appear as a running process.


Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites

...let me get this straight. You give someone this file/program that extracts the vncviewer and runs your AutoIt GUI. Then when your GUI closes VNC, the other program cannot clean up the VNC files "because vnchooks.dll is still in use".

...if I have the scenario correct, then I would suggest that you pick one of the following actions:

1) keep banging your head against that wall until you find what is locking the dll (in a post a while back, I think that I read about a tool that will tell you what is locking what - but I could not locate that info today)

or

2) change to another flavor of VNC.

I manually tested RealVNC 4.1 "free edition".

I connected to a remote system.

I disconnected.

I manually deleted all of the files in the VNC folder without a problem.

Caveats:

I'm not a fan of RealVNC.

Your mileage may vary....


[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

...let me get this straight. You give someone this file/program that extracts the vncviewer and runs your AutoIt GUI. Then when your GUI closes VNC, the other program cannot clean up the VNC files "because vnchooks.dll is still in use".

...if I have the scenario correct, then I would suggest that you pick one of the following actions:

1) keep banging your head against that wall until you find what is locking the dll (in a post a while back, I think that I read about a tool that will tell you what is locking what - but I could not locate that info today)

or

2) change to another flavor of VNC.

I manually tested RealVNC 4.1 "free edition".

I connected to a remote system.

I disconnected.

I manually deleted all of the files in the VNC folder without a problem.

Caveats:

I'm not a fan of RealVNC.

Your mileage may vary....

<{POST_SNAPBACK}>

Download this useful little tool.

Installs tiny and available from the right click context menu.

just right click on file, click wholockme and it'll tell you.

http://www.dr-hoiby.com/WhoLockMe/index.php

hth

Hardcopy


Contributions: UDF _DateYearFirstChildren are like Farts, you can just about stand your own.Why am I not a Vegetarian?...Well...my ancestors didn't fight & evolve to the Top of the food chain for me to survive on Salad

Share this post


Link to post
Share on other sites

Many thanks to all who took the time to try and help me.

I think I have solved the problem. Winvnc was not closing down properly and that was keeping vnchooks.dll active. I have modified my script to try and take care of this. I am adding my modified script in case it is of use to any less knowledgable than me in the art of programming (if that is possible).

#include <GuiConstants.au3>


Opt("GUIOnEventMode", 1)
Opt("TrayIconHide", 1)

; GUI
GuiCreate("Remote Control", 200, 300)

GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")

; PIC
GuiCtrlCreatePic("logo.bmp",10,10, 180,181,$SS_SUNKEN)

; BUTTON
$Button1=GuiCtrlCreateButton("Connect", 10, 250, 80, 30)
$Button2=GuiCtrlCreateButton("Close", 110, 250, 80, 30)

GUICtrlSetOnEvent($Button1, "ConnectButton")
GUICtrlSetOnEvent($Button2, "CloseButton")

; TEXT
GuiCtrlCreateLabel("Tel :- ***** ****** before Connect", 10, 210, 190, 30)
GUICtrlSetColor(-1,0xff0000)   ; Red

GUISetState(@SW_SHOW)

While 1
  Sleep(100) ; Idle around
WEnd

Func CLOSEClicked()
      Run("winvnc.exe -kill")
      $PID = ProcessExists("winvnc.exe"); Will return the PID or 0 if the process isn't found.
      If $PID Then ProcessClose($PID)
       Exit
 EndFunc

Func ConnectButton()
    $remote_Station = INPUTBOX("Remote Control", "Remote Control Address", "", "", -1, 120)
    Run("winvnc.exe -connect " & $remote_station)
EndFunc

Func CloseButton()
       Run("winvnc.exe -kill")
       $PID = ProcessExists("winvnc.exe"); Will return the PID or 0 if the process isn't found.
      If $PID Then ProcessClose($PID)
        Exit
EndFunc

BTW Herwasplato

Your understanding of the process is correct. I use the single click part of UltraVNC because it allows file transfer and has been modified to be used purely for reverse connection.



Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites

Although I have fixed the dll active problem I now have another one. When I close the program the tray icon stays visible until I attempt to put the cursor on top of it. I know there is MouseMove command available but how do I know the position to move the cursor to as people use different screen resolutions and have various tray icons visible.

Thanks in advance



Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites

Although I have fixed the dll active problem I now have another one. When I close the program the tray icon stays visible until I attempt to put the cursor on top of it. I know there is MouseMove command available but how do I know the position to move the cursor to as people use different screen resolutions and have various tray icons visible.

Thanks in advance

<{POST_SNAPBACK}>

1) you have 2 functions with the statements:

Run("winvnc.exe -kill")

      $PID = ProcessExists("winvnc.exe"); Will return the PID or 0 if the process isn't found.

      If $PID Then ProcessClose($PID)

      Exit

either should be able to be removed. (don't feel bad, happens frequently when you change strategies mid script)

2)right after your attempt to exit the program the right way run("winvnc.exe -kill") you have it kill the process if it's active... what i would suggest would be....

RunWait("winvnc.exe -kill","C:\");with the directory where your winvnc is located put in for the second parameter.  you may run into issues using a run()/runwait() with a parameter(if you see a second vnc pop up or if the window gets activated and doesn't do anything)if that happens, you may want to change

"winvnc.exe -kill"

to '"winvnc.exe -kill"'. all i did was surround the string with single quotes outside of the double quotes.

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

Thanks

I tried both the RunWait command and also removing winvnc -kill.

using the RunWait the winvnc program takes around 15 seconds to close

Using only the ProcessClose closes winvnc but leaves the tray icon as described in my previous post.

:whistle:



Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

I think core of problem is in using Run() instead of RunWait(),

so DLL is blocked because VNC isn't so quick and

code after Run() is executed immediatelly (too early).

Try it and if I'm right then PID code is obsolete there.

:whistle:

EDIT: Now I noticed, that somebody tell about RunWait before me, so sorry.

Edited by Zedna

Share this post


Link to post
Share on other sites

I think core of problem is in using Run() instead of RunWait(),

so DLL is blocked because VNC isn't so quick and

code after Run() is executed immediatelly (too early).

Try it and if I'm right then PID code is obsolete there.

:whistle:

<{POST_SNAPBACK}>

Does this mean there is no solution to the tray icon remaining and that I will just have to live with the 15 sec delay

:dance:



Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites

Does this mean there is no solution to the tray icon remaining and that I will just have to live with the 15 sec delay

:whistle:

<{POST_SNAPBACK}>

the reason the tray icon is staying, is because you're not exiting the program the right way, but instead stoppint the process. that's like ending the process in the task manager, it will have the same result. as far as the 15 seconds, that's just how long it takes for the program to exit i guess. did you try putting single quotes around your double quotes for the run('"winvnc.exe -kill"') that may do it also. personally i'd just change the line to a runwait (which you say you did) and surrounding your double quotes with single quotes on the file name to execute. also make sure to specify the working directory.

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

Does this mean there is no solution to the tray icon remaining and that I will just have to live with the 15 sec delay

:whistle:

<{POST_SNAPBACK}>

That depends, is there a "no icon" option with this VNC?

You stated, "Although I have fixed the dll active problem..."

What method of killing/closing VNC frees up the hooks DLL in under 15 seconds?

Maybe someone at UltraVNC has a faster close method or shutdown sequence.


[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

I have tried all that was suggested but none seem to make it better. I have settled on the RunWait method as it exits cleanly (all be it slowly) and allows the program to delete the files after use.

Many thanks for all your help.

Maybe I should leave programming to the experts.



Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites

That depends, is there a "no icon" option with this VNC?

You stated, "Although I have fixed the dll active problem..."

What method of killing/closing VNC frees up the hooks DLL in under 15 seconds?

Maybe someone at UltraVNC has a faster close method or shutdown sequence.

<{POST_SNAPBACK}>

The method of killing VNC fast is the ProcessClose one which leaves the tray icon. There is no "no icon" option with VNC. I did try removing the icon with reshack and using the ProcessClose method but decided against it as it did not let people see when they were still connected to my computer.


Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites

Maybe I should leave programming to the experts.

<{POST_SNAPBACK}>

nah, 'cause if the experts had said that when they were at the same stage as you (and every single one of them was at some point) then there'd be no experts to leave it to.

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0