| 
| 
| 
| #203747 - 2011-11-16 04:52 PM  Is there an opposite to CreateObject() ? |  
| ShaneEP   MM club member
 
       
   Registered:  2002-11-29
 Posts: 2127
 Loc:  Tulsa, OK
 | 
This is an old problem that I've managed to work around using getfileversion(), but just out of curiosity does anybody know how to release an object once it's created? I expected a simple $system = 0 to do the trick, but the file lock remains. Is it expected behavior for object creation, or is it just kixforms?
 In the below example, I can never replace kixforms.dll because the file remains locked.
 
 $System = CreateObject("Kixtart.Form")
if CompareVerString($System.Version, "2.47.5.1") = 1
   $System = 0
   $oldkf = ReadValue("HKEY_CLASSES_ROOT\CLSID\"+ReadValue("HKEY_CLASSES_ROOT\Kixtart.System\CLSID","")+"\InprocServer32","")
   Copy @ScriptDir+"\kixforms.dll" $oldkf
? @Error
? @SError
   $System = CreateObject("Kixtart.System")
endif
get $
Function CompareVerString($_Version1, $_Version2)
  Dim $_X, $_Max
  $_Version1 = Split($_Version1, '.')
  $_Version2 = Split($_Version2, '.')
  $_Max=IIf(UBound($_Version1)>UBound($_Version2),UBound($_Version1),UBound($_Version2))
  ReDim Preserve $_Version1[$_Max]
  ReDim Preserve $_Version2[$_Max]
  For $_X = 0 to $_Max
    Select
     Case CInt($_Version1[$_X]) < CInt($_Version2[$_X])
      $CompareVerString=1  Exit 0
     Case CInt($_Version1[$_X]) > CInt($_Version2[$_X])
      $CompareVerString=-1 Exit 0
    EndSelect
  Next
  Exit 0
EndFunction |  
| Top |  |  |  |  
| 
| 
| #203757 - 2011-11-16 09:29 PM  Re: Is there an opposite to CreateObject() ?
[Re:  ShaneEP] |  
| Allen   KiX Supporter
 
       
 Registered:  2003-04-19
 Posts: 4562
 Loc:  USA
 | 
Okay... will you try this?
 
 
$System=Nothing()
function Nothing()
  dim $sc
  $sc = CreateObject("ScriptControl")
  $sc.language = "VBScript"
  $sc.addcode('noth=nothing')
  $sc.run
  $nothing=$sc.codeobject.noth  
endfunction
 I am trying it now on sendmail.
 |  
| Top |  |  |  |  
| 
| 
| #203763 - 2011-11-16 11:31 PM  Re: Is there an opposite to CreateObject() ?
[Re:  Allen] |  
| ShaneEP   MM club member
 
       
   Registered:  2002-11-29
 Posts: 2127
 Loc:  Tulsa, OK
 | 
I dont seem to be having as much luck. Can you see something wrong with this? I tried to imitate what you did with sendmail().
 
 $sc=CreateObject("ScriptControl")
$sc.language = "VBScript"
$sc.addcode('noth=nothing')
$sc.run
$System = CreateObject("Kixtart.Form")
if CompareVerString($System.Version, "2.47.5.1") = 1
   $System=$sc.codeobject.noth
   $oldkf = ReadValue("HKEY_CLASSES_ROOT\CLSID\"+ReadValue("HKEY_CLASSES_ROOT\Kixtart.System\CLSID","")+"\InprocServer32","")
   Copy @ScriptDir+"\kixforms.dll" $oldkf
   ? @Error
   ? @SError
endif
get $
Function CompareVerString($_Version1, $_Version2)
  Dim $_X, $_Max
  $_Version1 = Split($_Version1, '.')
  $_Version2 = Split($_Version2, '.')
  $_Max=IIf(UBound($_Version1)>UBound($_Version2),UBound($_Version1),UBound($_Version2))
  ReDim Preserve $_Version1[$_Max]
  ReDim Preserve $_Version2[$_Max]
  For $_X = 0 to $_Max
    Select
     Case CInt($_Version1[$_X]) < CInt($_Version2[$_X])
      $CompareVerString=1  Exit 0
     Case CInt($_Version1[$_X]) > CInt($_Version2[$_X])
      $CompareVerString=-1 Exit 0
    EndSelect
  Next
  Exit 0
EndFunction |  
| Top |  |  |  |  
| 
| 
| #203765 - 2011-11-16 11:51 PM  Re: Is there an opposite to CreateObject() ?
[Re:  Lonkero] |  
| ShaneEP   MM club member
 
       
   Registered:  2002-11-29
 Posts: 2127
 Loc:  Tulsa, OK
 | 
I assumed the same as you're saying, but it just doesn't. If I run the below test script I get error 32 "The process cannot access the file because it is being used by another process.". Even withe the redim and a 15 second sleep.
 
 $System = CreateObject("Kixtart.Form")
if $System.Version <> "2.47.5.1"
   $System = 0
   ReDim $System
   Sleep 15
   $oldkf = ReadValue("HKEY_CLASSES_ROOT\CLSID\"+ReadValue("HKEY_CLASSES_ROOT\Kixtart.System\CLSID","")+"\InprocServer32","")
   Copy @ScriptDir+"\kixforms.dll" $oldkf
   ? @Error
   ? @SError
endif
get $ |  
| Top |  |  |  |  
 Moderator:  Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart
 
 | 
| 
 
| 0 registered
and 456 anonymous users online. 
 | 
 |  |