From: Park Heesob Date: 2006-05-25T11:59:46+09:00 Subject: Re: Ruby / DL problem Hi, >From: Bama Test >Reply-To: ruby-talk@ruby-lang.org >To: ruby-talk@ruby-lang.org (ruby-talk ML) >Subject: Ruby / DL problem >Date: Thu, 25 May 2006 01:35:06 +0900 > >I've got a DLL that I'm working on interfacing to - i've got everything >working except for this one function. > >int CreateDataFile ( const char* csUserID, > const char* chOptionalTemplateFilePath, > const char* csPrefix, > const char* csSuffix, > char*& newFileID); > >the problem is with the newFileID parameter - it's defined as "points >to the buffer that receives the string of the File ID created. Maximum >length of this buffer is 20 bytes." > >I've tried defining the call as both >@createfile = msg["CreateDataFile", "ISSSSP"] >and >@createfile = msg["CreateDataFile", "ISSSSS"] > >and then passing in the values like this >x = "" >ptr = DL.malloc(20) >a = @createfile.call('eldon',x,x,x,ptr) > >the function runs successfully but I can't ever retrieve the value of >the FileID created from ptr and from what I can tell It still looks >empty. So I figure I must either be defining it incorrectly or passing >it in the call wrong. From my memory of C the & is actually a pointer >to a memory location, but there seems something in my memory that it >might mean something different when referenced like this (it's been >like 10 years since i did anything in C) and I've done a ton of google >searches already. > >Any guesses as to what i might be doing wrong? > define like this @createfile = msg["CreateDataFile", "ISSSSP"] and call like this ptr = "\0" * 20 a = @createfile.call('eldon',x,x,x,[ptr].pack("P")) puts ptr Regards, Park Heesob