Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Autmoate Resrv32 functions 3

Status
Not open for further replies.

lashwarj

IS-IT--Management
Joined
Nov 1, 2000
Messages
1,067
Location
US
Is there a way to automatically run files through regsrv32 instead of having to do it manually. I have a few that run my crystal reports and was wondering how to make it so when the user installed the application they did not have to go in and regsrv the files
 
You could copy your .ocx and dll's in your application directpry and register them there.

Code:
DECLARE myArray[1]
CD "c:\program files\imageX"
nCount=ADIR(myArray,"*.ocx")
FOR i = 1 TO nCount
  LOCAL cFileName
  STORE myArray[i,1] TO cFileName
  !/n regsvr32 &cfilename
NEXT
[code]
  [b][i]Mike Gagnon[/i][/b]

[i]If you want to get the best response to a question, please check out FAQ184-2483 first or check this link [URL unfurl="true"]http://www.tuxedo.org/~esr/faqs/smart-questions.html[/URL][/I]
 
You might also want to run REGSVR32 with the /s (silent) option to suppress the messageboxes saying it succeeded.

Andy
 
Or, you can avoid the Command Shell entirely:

DO RegSvr WITH "myActiveXfile.ocx"

Code:
PROC RegSvr
LPARAMETERS pcOCX
DECLARE INTEGER LoadLibrary IN kernel32 As "LoadLibraryA"; 
    STRING lpLibFileName 

LOCAL lhLib
lhLib = LoadLibraryA( pcOCX )

if (lhLib < 32) && HINSTANCE_ERROR
  RETURN &quot;ERROR: Could not Load Library &quot;+pcOCX
ENDIF

*// Find the entry point.
DECLARE INTEGER GetProcAddress IN kernel32;  
    INTEGER hModule,;  
    STRING lpProcName
    
lpRegProc = GetProcAddress(lhLib, 'DllRegisterServer')
if lpRegProc>0 && Procedure exists!
  DECLARE INTEGER DllRegisterServer IN &pcOCX AS OcxReg 
  lnRes = OcxReg()
  if lnRes=0
    RETURN &quot;SUCCESS&quot;
  else
    RETURN &quot;ERROR: DllRegisterServer returned &quot;+Tran(lnRes)
  endif
ELSE
  * //unable to locate entry point
  RETURN &quot;ERROR: Library &quot;+pcOCX+&quot; has no entry point for DllRegisterServer&quot;
ENDIF
 
Or you can just say &quot;SCREW IT&quot; open up another BEER and forget that anyone asked you to make the change.

[bigears]

well it was a thought...
 
lashwarj

Does this thread mean you are still having problems distributing your Crystal DLLs with you application?

Did you try adding them as COM components as suggested in the other thread? This is how I do it and have never had a problem.

Could it be a system permissions thing on the client's machine? Are they logged in as administrator when they install your application?

Neil &quot;I love work. I can sit and stare at it for hours...&quot;
 
WGCS
I really enjoyed the code you shared for avoiding the command shell (regsvr32)...just wanted to let you know that it has been cut and pasted into my library...thanks Slighthaze = NULL
 
You're very welcome!

I thought a few might like it; We distribute &quot;Plug in&quot; features separately from our main programs, and these sometimes need ActiveX controls... InstallShield/etc. are overkill for the plug-ins, but just using a file picker from the main program, extracting the ancilliary files (including .OCX's) then using this method to register them works great! That way we can distribute plug-ins as a single .APP file.
 
I am all set guys I appreciate the assistance, sorry for the delay, I made a prg file that runs once and does my registering. The user has to select no to it running again but it worked great, thank you for your assistance
 
An approach you might consider is installing a file named something like &quot;INSTALL.NEW&quot; with the program. The first time it is run, it sees that file, does all the registering (and, more important for us, converting data to current format), then deletes the INSTALL.NEW file. This removes the user interaction to avoid repeating once-only processes.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top