Sign in to follow this  
Followers 0
oyo113

Got Error When Return String from DLL

1 post in this topic

.cpp

#include "main.h"
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <iostream>
using namespace std;

// a sample exported function
string test_name()
{
    return "test";
}
===============================
#ifndef __MAIN_H__
#define __MAIN_H__

#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <iostream>
using namespace std;

/*  To use this exported function of dll, include this header
 *  in your project.
 */

#ifdef BUILD_DLL
    #define DLL_EXPORT __declspec(dllexport)
#else
    #define DLL_EXPORT __declspec(dllimport)
#endif


#ifdef __cplusplus
extern "C"
{
#endif

string DLL_EXPORT test_name();

#ifdef __cplusplus
}
#endif

#endif // __MAIN_H__

 

 

#include <MsgBoxConstants.au3>
$test = DllCall("testdll.dll", "wstr:cdecl", "test_name","none")
MsgBox(0,"",$test[0])

How to get string from my dll? Thanks.

Share this post


Link to post
Share on other sites



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0