|
-
Jun 16th, 2004, 08:32 PM
#1
Thread Starter
Fanatic Member
cpp DLL returns garbage to VB
PHP Code:
#include <windows.h>
#include <string>
#include <vector>
using namespace std;
char * __stdcall enumerateFiles ( char * startPath, char * searchPattern) {
string directoryName;
string fileName ;
string temporary;
string returnValue;
vector<string> directoryNames;
int numberDirectories = 0;
int cont = 0;
HANDLE hFind;
WIN32_FIND_DATA wfd;
cont = 1;
temporary = startPath;
temporary += "*";
hFind = FindFirstFile(temporary.c_str(), &wfd);
if (hFind != INVALID_HANDLE_VALUE) {
while ( cont ) {
directoryName = wfd.cFileName;
if ( (directoryName != ".") && ( directoryName != "..") ) {
temporary = startPath;
temporary += directoryName;
if ( GetFileAttributes(temporary.c_str()) && FILE_ATTRIBUTE_DIRECTORY ) {
directoryNames.push_back (directoryName);
numberDirectories++;
}
}
cont = FindNextFile(hFind, &wfd);
}
cont = FindClose(hFind);
}
temporary = startPath;
temporary += searchPattern;
hFind = FindFirstFile(temporary.c_str(), &wfd);
cont = 1;
if ( hFind != INVALID_HANDLE_VALUE ) {
while ( cont ) {
fileName = wfd.cFileName;
if ( (fileName != ".") && (fileName != "..") ) {
temporary = startPath;
temporary += fileName;
returnValue = returnValue + temporary + ';';
}
cont = FindNextFile(hFind, &wfd);
}
cont = FindClose(hFind);
}
if (numberDirectories > 0) {
for ( int i = 0; i < numberDirectories; i++ ) {
temporary = startPath;
temporary = temporary + directoryNames[i] + "\\";
enumerateFiles( (CHAR * )temporary.c_str(), searchPattern);
}
}
return (CHAR *)returnValue.c_str();
}
Alot to look at but it works, anyway, this works fine when I use cout to display the data as it comes in, but when it comes to telling VB whats up it returns mostly those Y's with the accent over it. I think it has something to do with the fact I am using string class, but I don't know, maybe someone else has some more insight as to what im doing wrong.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|