?
Solved

MFC DLL Primer

Posted on 2000-01-04
4
Medium Priority
?
226 Views
Last Modified: 2013-11-20
Having created an (shared) MFC DLL Project using MSVC++ app wizard, I now want to implement a function that takes a string argument.

This dll will be called from a VB app, so I am also unsure as to whether the function declaration should be using VARIANTS...
0
Comment
Question by:jhattingh
  • 2
4 Comments
 
LVL 4

Accepted Solution

by:
inpras earned 200 total points
ID: 2322726
Hi
Do this
in UR dll
extern "C" __declspec(dllexport) ExportedFunction(LPSTR str);

ExportedFunction(LPSTR str)
{
             // str will have the value
}

remember it takes only null terminated string.
in vb U can initialize UR string with all 0 s and pass it
copy the value U want to pass
if U don't want to pass null terminated string then defin as follows
ExportedFunction(LPSTR str, int nLength)
where nLength U will be passing from vb's string length

Hope this helps
0
 
LVL 1

Author Comment

by:jhattingh
ID: 2322742
It looks useful, but may I ask why the function is notmadeamember of the C...App class created by AppWizard?
0
 
LVL 3

Expert Comment

by:akalmani
ID: 2324978
Hi !!!
   Yes inpras is right.
If u want to export the class itself then u can make it member function of App class and export the class itself or just export the required function.
0
 
LVL 4

Expert Comment

by:inpras
ID: 2325126
Hi
Make it a member function no problem
like
CDllStaticTextApp::ExportedFunction(LPSTR str)
{
}

in .h file declaration
      __declspec(dllexport) ExportedFunction(LPSTR str);

Hope this helps
Regards
0

Featured Post

Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Stellar Phoenix SQL Database Repair software easily fixes the suspect mode issue of SQL Server database. It is a simple process to bring the database from suspect mode to normal mode. Check out the video and fix the SQL database suspect mode problem.
Suggested Courses

601 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question