View Single Post
Old Feb 18th, 2005, 5:37 PM   #1
Floppie
Newbie
 
Join Date: Feb 2005
Posts: 18
Rep Power: 0 Floppie is on a distinguished road
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 is offline   Reply With Quote