Wrong and unsafe ...
DLLIMPORT DWORD DBP_GetHostByName(LPSTR DBP_HostName)
{
LPSTR DBP_HostAddress;
DBP_RemoteHost = gethostbyname( DBP_HostName );
DBP_HostAddress = (DBP_RemoteHost->h_addr);
return (DWORD)DBP_HostAddress;
}
The right way ...
DLLIMPORT DWORD DBP_GetHostByName(LPSTR OldString, LPSTR DBP_HostName)
{
LPSTR DBP_HostAddress;
// Release the string we are replacing
if (OldString)
Core->CreateDeleteString( (DWORD*)&OldString, 0 );
DBP_RemoteHost = gethostbyname( DBP_HostName );
DBP_HostAddress = (DBP_RemoteHost->h_addr);
// Allocate a new string and fill it in
LPSTR Result;
Core->CreateDeleteString( (DWORD*)&Result, strlen(DBP_HostAddress)+1 );
strcpy( Result, DBP_HostAddress );
return (DWORD)Result;
}
... or something like that. You have to use DBPro memory-management system when playing with strings.
[edit]
The resource string would be:
GET HOST BY NAME[%SS%DBP_GetHostByName%Hostname