首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

c++写dll的有关问题,string

2012-02-29 
c++写dll的问题,string我建立了一个dll的工程。//lib.h#ifndefLIB_H#defineLIB_H#includewindows.h#inclu

c++写dll的问题,string
我建立了一个dll的工程。
//lib.h
#ifndef   LIB_H
#define   LIB_H
#include   <windows.h>
#include   <iostream>
#include   <string>
using   namespace   std;
int   add(int   a,int   b);
string   appstring(string   a);
#endif  

//lib.cpp
#include   "lib.h "

BOOL   APIENTRY   DllMain(HANDLE   hModule,        
    DWORD     ul_reason_for_call,  
    LPVOID   lpReserved
    )
{
        switch   (ul_reason_for_call)
{
case   DLL_PROCESS_ATTACH:
printf( "\nprocess   attach   of   dll ");
break;
case   DLL_THREAD_ATTACH:
printf( "\nthread   attach   of   dll ");
break;
case   DLL_THREAD_DETACH:
printf( "\nthread   detach   of   dll ");
break;
case   DLL_PROCESS_DETACH:
printf( "\nprocess   detach   of   dll ");
break;
        }
        return   TRUE;
}
int   add(int   a,int   b)
{
return   a+b;
}
string   appstring(string   a)
{
string   c=a+ "! ";
return   c;
}

//lib.def
LIBRARY   LIB
EXPORTS
add   @   1
appstring   @   2

3个文件如上。add可以正常工作,可appstring就不行了。谁能告诉我是为什么啊。难道是对string的支持有问题么。怎么改呢。谢谢

[解决办法]
string appstring(string a);
使用参数返回你要返回的东西。
[解决办法]
不要在dll里导出class,或者参数需要class,水太深了。
用char *

热点排行