Hi there everyone
I have made a very useful function for people who need help returning strings(such as me) this was made in devc++ but it should work in msvc++6
Returning strings is easy now though
in msvc++ u wont need to do anything really all u do is use this code
GlobStruct *g_pGlob;
void ReceiveCoreDataPtr( void *cdp ){
g_pGlob = (GlobStruct *) cdp;
}
DWORD dbpstring(LPSTR pstring)
{
LPSTR pret=NULL;
DWORD dwSize=strlen((LPSTR)pstring );
g_pGlob->CreateDeleteString ( (DWORD*)&pret, dwSize+1 );
strcpy(pret, (LPSTR)pstring);
return (DWORD) pret;
}
and u do not need to put dbpstring or receivecoredatapointer in your stringtables but u need to get the function name and make stringtables for your functions as u normally would
it is pretty easy for msvc++ right?
well it is just a tad bit harder in devc++
first of all u need a .def file so make file and rename it whatever.def and then goto project options then to the paremeters tab and in the linker box add this: --def whatever.def
then add this code to whatever.def
LIBRARY MY_PROJECT_NAME
EXPORTS
?ReceiveCoreDataPtr@@YAXPAX@Z=_Z18ReceiveCoreDataPtrPv
NAME=MANGLEDNMAE
.def files completely override __declspec() sou can attach it or u can decide not to
name=mangledname is whatever u want the name of the function to be(this should be used as: fname%0%NAME_YOU_PUT_THERE) and the mangled name can be found by opening the binary dll up in notepad and searching for your function name
and u also need to include globstruct and if u havent installed and configed directx 9.0 SDK then u need to(add the include path to the devc++ includes, add path to the directx libs in both c and c++)
i hope everyone can understand the devc++ part
also to return a string u need to return a dword in your function
EDIT:
example
GlobStruct *g_pGlob;
void ReceiveCoreDataPtr( void *cdp ){
g_pGlob = (GlobStruct *) cdp;
}
DWORD dbpstring(LPSTR pstring)
{
LPSTR pret=NULL;
DWORD dwSize=strlen((LPSTR)pstring );
g_pGlob->CreateDeleteString ( (DWORD*)&pret, dwSize+1 );
strcpy(pret, (LPSTR)pstring);
return (DWORD) pret;
}
DWORD say_hello(void){
char* rety;
rety="hello!";
return dbpstring(rety);
}
example def file
LIBRARY MY_PROJECT_NAME
EXPORTS
?ReceiveCoreDataPtr@@YAXPAX@Z=_Z18ReceiveCoreDataPtrPv
;NAME=MANGLEDNMAE so therefor
say_hello_to_all=_Z18say_hello ;i did not compile this so i dont know the mangled name
;if you just wanted the mangled name then you could just type the mangled name and no ='s or anything after it like say_hello and that would export it
and example string table
;don't know the string table headers needed
1,SAY HELLO[%S0%say_hello_to_all ;the 0 means no paremeters
and thats it
tutorials,programs,useful but simple php scripts, a place for code snipplets and more at
http://hackr83.0z0.co.uk
(still under construction)