65,176
社区成员




#include "stdafx.h"
#include <string>
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}
extern "C" __declspec(dllexport) void getstring(std::string& s)
{
s = "abcdefg";
}
#include "stdafx.h"
#include <windows.h>
#include <iostream>
#include <string>
using namespace std;
#pragma comment(lib, "..\\debug\\stringdlla.lib")
extern "C" __declspec(dllimport) void getstring(std::string& s);
typedef void (*pf)(std::string&);
char *p1 = "hello world!";
void test(string& str);
pf f;
int main()
{
#ifdef DUBUG
HINSTANCE h =LoadLibrary(L"..\\debug\\stringdlla.dll");
#else
HINSTANCE h =LoadLibrary(L"stringdlla.dll");
#endif
f = (pf)GetProcAddress( h, "getstring");
string st;
test(st);
cout << st;
getstring(st);
cout << st;
f(st);
cout << st;
return 0;
}
void test(string& str)
{
str = p1;
}