要生成dll,但当中要调用lib,要怎么做。 20
#include<windows.h>#include"mysql.h"#include<conio.h>#include"stdafx.h"#pragmacomment...
#include <windows.h>
#include "mysql.h"
#include <conio.h>
#include "stdafx.h"
#pragma comment(lib,"libmysql.lib")
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}
extern "C" _declspec(dllexport)char* mysql(void)
{
MYSQL *conn;
MYSQL_RES *res;
MYSQL_ROW row;
char *server = "localhost";
char *user = "root";
char *password = "root";
char *database = "labview";
conn = mysql_init(NULL);
mysql_real_connect(conn, server, user, password, database, 3306, NULL, 0);
char sql[1024]="SELECT * FROM labview WHERE ID=8383";
mysql_query(conn, sql);
res = mysql_use_result(conn);
row = mysql_fetch_row(res);
mysql_free_result(res);
mysql_close(conn);
return row;
} 展开
#include "mysql.h"
#include <conio.h>
#include "stdafx.h"
#pragma comment(lib,"libmysql.lib")
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}
extern "C" _declspec(dllexport)char* mysql(void)
{
MYSQL *conn;
MYSQL_RES *res;
MYSQL_ROW row;
char *server = "localhost";
char *user = "root";
char *password = "root";
char *database = "labview";
conn = mysql_init(NULL);
mysql_real_connect(conn, server, user, password, database, 3306, NULL, 0);
char sql[1024]="SELECT * FROM labview WHERE ID=8383";
mysql_query(conn, sql);
res = mysql_use_result(conn);
row = mysql_fetch_row(res);
mysql_free_result(res);
mysql_close(conn);
return row;
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询