Dll in C++

header
header used Ask the Experts™
on
Does anyone know how to make a .dll in C++?  Could someone send me the source code for a rather simple dll.  Maybe just three or four functions.

A function to input a filename and return the filename making sure there is a trailing slash.

A function to input a filename and check to see if it exists.

And a couple other various tasks.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
If you have the MSDN CDs, there are some pretty good sample C++ DLLs included with it using the Active Template Library (ATL).  

Inside of MSDN do a Search on 'ATL Samples Index', this will bring up a list of sample projects! :>)

Author

Commented:
The samples you mentioned are still a little too advanced for me.  I can't make heads or tails of what is going on.  That is why I want just a simple dll shown to me so I can see how things flow and then build on that.

Commented:
Check out this site:

http://www.genusa.com/isapi/makedll.html


Cheers!
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

This is the code for a dll which has the function to check for a trailing slash

// toolsdll.cpp //

#include <windows.h>

// This function is the starting point for a Dll, you don't have to change it
BOOL APIENTRY DllMain( HANDLE hModule,
                       DWORD  ul_reason_for_call,
                       LPVOID lpReserved
                               )
{
    return TRUE;
}

char * CALLBACK CheckTrailingSlash(char*string)
{
      if (string[strlen(string-1)]!='\\') strcat(string,"\\");
      return string;
}

// End of toolsdll.cpp //

// toolsdll.def //

LIBRARY toolsdll
EXPORTS
CheckTrailingSlash

// End of toolsdll.def //

You could use this dll by declaring like this in your vb-project:

declare function CheckTrailingSlash lib "toolsdll.dll" (byref str as string) as string

Author

Commented:
mcrider, thanks but the project that is created is blank.  What I need is an already existing project (not too complicated) that I can look at.

Author

Commented:
gambistics, that looks like it might be what I want, however I am having trouble compiling it.  Could you package it all up into a workspace and e-mail it to me?

header@rocketmail.com

Commented:
header,

There are several DLL examples in the "Source Code Repository" at the link I gave you... Just click on the link above and then click "Source Code Repository"



Cheers!

Author

Commented:
gambistics, thanks for the sample project.  Everything makes much more sense now.

mcrider, thanks for your help as well.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial