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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling a VFP 6 dll from Visual Basic

Status
Not open for further replies.

grahamrhind

Technical User
Jul 8, 2003
99
0
0
A1
Hello,

I have written a VFP 6 dll, which I have tested and which works without problem when called from the VFP environment.

A tester is now trying to access this same dll from a non-VFP environment, calling using Visual Basic code.

The tester has succeeded in creating the object. However, when sending data to one of the methods, he gets the error:

Error: Automation error, Library not registered.

Example code to access the dll from VFP is:

oTemp=CREATEOBJECT("grctools.grctools")
GRCReturnedString=oTemp.nonnum('1234-5678-90',1)

The code being used in VB is:

Dim oGrcTools As Object
Set oGrcTools = CreateObject("grctools.grctools")
txtOutput.Text = oGrcTools.nonnum(txtInput.Text, 1)

A couple of questions about this:

1) Does anybody have any experience with something like this - can they identify where the problem(s) lie?
2) When one runs the setup wizard from VFP to make a distributable exe (which the tester has done), is a different set of files included for a VFP .exe file than when distributing a .dll file? I noticed when trying to create a setup for the .dll that the distribution file was twice as large as for an .exe file, but I'm wondering what this is related to. If a different set of files are required, that may be the issue.

Many thanks in advance!
 

Graham,

The problem doesn't lie in the code. It occurs because this is a COM DLL, and has to be registered on the client's system. The setup wizard will only do this if you tell it to. It's been a long time since I used this wizard, but I vaguely remember a step where you specifically list your COM components.

The other option is to manually register by means of REGSVR32.EXE.

The reason it worked in VFP was that, when you ran the build, this automatically registered the component on your system.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
Hi Mike,

That sounds completely sensible - I'll give it a try!

Graham
 
Hi,

I've tried this, and it has no resolved the issue. The beta tester is getting the same error on his system, though he says that the .dll is being registered. When I run his VB .exe on my system (which has VFP but not VB installed, except VB runtime), it works fine. Does anybody know what I'm missing?

Thanks,

Graham
 

Graham,

That sounds like the VFP runtime files aren't installed on the tester's system. You mentioned you used the setup wizard, but did you explicitly say you wanted it to install the runtimes? There's a checkbox for that near the start of the wizard -- about page 2 if I remember right.

That explanation would be consistent with it working OK on your own system. Although you might not have run the setup program, the fact that you have VFP installed means you also have the runtimes.


Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
Hi Mike,

Thanks again, but that option was already checked. I'm running out of ideas :-(

Graham
 
Graham:
It seems you are missing a runtime file that is required by your dll. Try compiling the dll as an exe and noting if additional runtime files are added. Though I can't bring the specifics to mind right at the moment, I had a similar problem. My dll was creating an object, and in doing so required extra runtime file (beyond vfp6renu.dll, vfp6run.dll, and vfp6r.dll). I'll dig out my documentation and let you know what I find.

Dan

Dan Walter
Daniel.Walter@uvm.edu
try { succeed(); } catch(E) { tryAgain(); } finally { rtfm(); }
 
Thanks Dan. But how can I see which runtime files are added? None are added to the directory to which the program is installed, and I wouldn't know how to check whether VFP is writing files to other places on my disk. Also, as I already have VFP installed, I don't know what might be added new.

But the three .dlls that you mentioned are new to me, so I'll try to find those and send them to the beta tester ...

Graham
 
Further to this, Dan, I have VFP6R.DLL and VFPRENU.DLL in the \windows\system32 directory, but no VFPRUN6.DLL anywhere. I also have a file called VFP6ENU.DLL in the main VFP directory. Am I missing a file? Thanks in advance for looking this up for me!

Graham
 
Hi,

I install four runtime support files with each vfp application, I put them all in the system32 folder:

Code:
VFP6R.DLL
VFP6RENU.DLL
VFP6RUN.EXE
VFP6T.DLL

If they are all there you should do fine.

Note: VFP6RUN.EXE not VFP6RUN.DLL

Regards

Griff
Keep [Smile]ing
 
Incredibly, it appears that the resolution of this problem lies not in the libraries included with the DLL, but the fact that the regional settings on the source PC are not the same as those on the test PC. When the regional settings on the test PC are changed to those of the source PC, the error disappears. This is descibed at


for future reference ....

Graham
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top