Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Creating a DLL of a function to call from VFP
Message
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
VB 9.0
Miscellaneous
Thread ID:
01325489
Message ID:
01325534
Views:
20
>Trying to clarify my understanding :
>
>I have a function in VB .net (checks to see the current status of a printer) Receives a param of type string, returns an integer. I would like to create a DLL that I can call from VFP to get that integer after passing it the string.
>
>Do I just put the function in a module, compile it as a DLL, register it, and the do a oprinterchecker=creatobject('Printerchecker')
>lnstatus=oprinterchecker.PrintStatus("\\server\LaserPrinter")
>
>or is there something else I need to be thinking about?
>

Essentially, yes. You do need to mark the assembly under the build options to "Register for COM interop". On the classes that you want to expose add attributes right above the class definition like:
[ClassInterface(ClassInterfaceType.AutoDual)]
[ProgId("MyDllName.Class")]
[ComVisible(true)]
ProgId is optional - you can remove it and it will generate the COM object name based off of the assembly name.

You can add [ComVisible(true)] above the class, or above specific methods to control the visibility in the created COM object. Actually, now that I think about it, I think the default for com visibility is true. So to control method visibility (to hide methods), you'd use [ComVisible(false)].
-Paul

RCS Solutions, Inc.
Blog
Twitter
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform