Click here to Skip to main content
15,921,884 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionHow to pass string in DLL? Pin
Member 184868012-Apr-05 0:04
Member 184868012-Apr-05 0:04 
QuestionHow to pass string in DLL? Pin
Member 184868012-Apr-05 0:01
Member 184868012-Apr-05 0:01 
AnswerRe: How to pass string in DLL? [edited] Pin
toxcct12-Apr-05 0:08
toxcct12-Apr-05 0:08 
GeneralRe: How to pass string in DLL? Pin
Cedric Moonen12-Apr-05 1:31
Cedric Moonen12-Apr-05 1:31 
GeneralRe: How to pass string in DLL? [edited] Pin
Cedric Moonen12-Apr-05 2:06
Cedric Moonen12-Apr-05 2:06 
AnswerRe: How to pass string in DLL? Pin
Francesco Aruta12-Apr-05 8:46
Francesco Aruta12-Apr-05 8:46 
GeneralRe: How to pass string in DLL? Pin
Rick York12-Apr-05 9:30
mveRick York12-Apr-05 9:30 
GeneralRe: How to pass string in DLL? Pin
Francesco Aruta12-Apr-05 9:53
Francesco Aruta12-Apr-05 9:53 
Rick York wrote:
Your idea was right as was your comment but your implementation does not use the max_size parameter.

'couse I'm lazy! Smile | :) I thought that I solved that problem with my " //use max_size to prevent buffer overflow" Wink | ;)

Rick York wrote:
Shouldn't that be : strncpy( str, "hallo world", max_size ); ?

yes.. this should a good implementation. Personally I usually use something like:

<br />
int dll_func(char* str,int max_size)<br />
{<br />
//use max_size to prevent buffer overflow ok.. I'm writing it :)<br />
<br />
const char dll_str[] = "hallo world!"; //assume that this is a variable caming from somewhere in the dll<br />
<br />
strncpy(str,"hallo world!",max_size);<br />
return strlen(dll_str);<br />
}<br />


so in main process you can check (if (dll_func(str,strsize) > strsize) ) if you have truncated the string and the real/needed size.

Bye,
Francesco Smile | :)
GeneralRe: How to pass string in DLL? Pin
Cedric Moonen12-Apr-05 20:55
Cedric Moonen12-Apr-05 20:55 
GeneralRe: How to pass string in DLL? Pin
Francesco Aruta13-Apr-05 0:19
Francesco Aruta13-Apr-05 0:19 
GeneralForwardReferencing in VC++ 6.0 Pin
Ganesh_Srim11-Apr-05 23:35
Ganesh_Srim11-Apr-05 23:35 
GeneralRe: ForwardReferencing in VC++ 6.0 Pin
toxcct11-Apr-05 23:57
toxcct11-Apr-05 23:57 
GeneralRe: ForwardReferencing in VC++ 6.0 Pin
Ganesh_Srim12-Apr-05 9:13
Ganesh_Srim12-Apr-05 9:13 
GeneralRe: ForwardReferencing in VC++ 6.0 Pin
Joel Holdsworth12-Apr-05 0:18
Joel Holdsworth12-Apr-05 0:18 
GeneralRe: ForwardReferencing in VC++ 6.0 Pin
CP Visitor12-Apr-05 4:44
CP Visitor12-Apr-05 4:44 
GeneralRe: ForwardReferencing in VC++ 6.0 Pin
Ganesh_Srim12-Apr-05 9:16
Ganesh_Srim12-Apr-05 9:16 
GeneralRe: ForwardReferencing in VC++ 6.0 Pin
Bob Helter12-Apr-05 10:11
sussBob Helter12-Apr-05 10:11 
GeneralRe: ForwardReferencing in VC++ 6.0 Pin
Ganesh_Srim12-Apr-05 23:12
Ganesh_Srim12-Apr-05 23:12 
GeneralRe: ForwardReferencing in VC++ 6.0 Pin
Blake Miller12-Apr-05 7:31
Blake Miller12-Apr-05 7:31 
GeneralRe: ForwardReferencing in VC++ 6.0 Pin
Ganesh_Srim12-Apr-05 9:10
Ganesh_Srim12-Apr-05 9:10 
GeneralRe: Tried All - NoLuck! Pin
Ganesh_Srim12-Apr-05 9:26
Ganesh_Srim12-Apr-05 9:26 
GeneralRe: Tried All - NoLuck! Pin
Rick York12-Apr-05 9:48
mveRick York12-Apr-05 9:48 
GeneralRe: Tried All - NoLuck! Pin
CP Visitor12-Apr-05 22:55
CP Visitor12-Apr-05 22:55 
GeneralRe: Tried All - NoLuck! Pin
Ganesh_Srim12-Apr-05 23:17
Ganesh_Srim12-Apr-05 23:17 
GeneralRe: Tried All - NoLuck! Pin
Ganesh_Srim12-Apr-05 23:12
Ganesh_Srim12-Apr-05 23:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.