Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   C++ (http://www.programmingforums.org/forum15.html)
-   -   Calling a C++ DLL in VB (http://www.programmingforums.org/showthread.php?t=2342)

Floppie Feb 18th, 2005 4:37 PM

Calling a C++ DLL in VB
 
I wasn't real sure which to put this in, so I figured C++, as that seems to be where the problem lies.


I was looking to have my webserver output to a timestamped log file instead of its log window, and instead of looking around for info on how to write to a file in VB (reading from a file I had to learn obviously, as it has to read the file and send it), I simply created a function in C++ to add a log line for me.

Anyway, I'm getting this VB run-time error. "Can't find DLL entry point outfile in filestreamdll.dll". I have tried aliasing the function any way I found possible, utilizing any decoration in the .DLL/.LIB files ("?outfile@@YAHABVString@@0ABH@Z" being the total decoration I was able to find), but with any combination of decoration in there I still recieved the error message.

For reference, I'll include any vital info here. This is my complete DllMain() function, as I didn't feel as though I needed any real initialization/deinitialization for it:
:

BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
    switch (ul_reason_for_call)
        {
                case DLL_PROCESS_ATTACH:
                case DLL_THREAD_ATTACH:
                case DLL_THREAD_DETACH:
                case DLL_PROCESS_DETACH:
                        break;
    }
    return TRUE;
}



The only function's prototype (I enumerated app and trunc to 0 and 1, respectively):
:

__declspec(dllexport) int outfile(const String &strOutString, const String &strFile,
    const int &filemode = app);


String being a standard class I used to make dynamic char arrays easier. The prototype to its relevant constructor is:
:

String::String(const char * s);

My attempt at calling the function from VB:
:

Public Declare Function outfile Lib "filestreamdll.dll" _
    (ByRef strOutString As String, ByRef strFile As String, ByRef filemode As Integer) _
    As Integer



My attempt at actually utilizing the function from VB:
:

outfile_return = outfile("Start Session @" & GetFormattedTime() & Chr$(10), _
    "httplog.log", 0)


GetFormattedTime() returns a string with the date in it, formatted.
If anything else is needed, just say so.

Floppie Feb 20th, 2005 12:08 PM

Found my problem. I forgot to create a .def file in my project. I couldn't for the life of me find any way to edit my intial post to add "[solved]" to the title; maybe I'm just being blind, but if a mod could edit that or show me where the edit button is, that'd be great...thank you~

EDIT: Hmm...edit button on this post but not the first. Odd.


All times are GMT -5. The time now is 4:30 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC