Jump to content

wegstar

Members
  • Posts

    2
  • Joined

  • Last visited

Everything posted by wegstar

  1. Thank you martin and picasso! It seems to work here
  2. Hello, I am currently making a mysql UDF which directly calls functions in libmysql.dll. However, I am having trouble handling an array of strings (char**, char*[], char [][]) that is returned by the mysql_fetch_row() function. As you can see in my code, I've figured out how to deal with returned char* strings...: CODEFunc mysqlQuery($query) $queryprep = DllStructCreate("char[" & (StringLen($query)+1) & "]") DllStructSetData($queryprep, 1, $query) $queryptr =DllStructGetPtr($queryprep, 1) # we'll add on 100 to be sure $bufferprep = DllStructCreate("char[" & (StringLen($query)+100) & "]") $buffer =DllStructGetPtr($bufferprep, 1) Local $temp = DllCall($dll, "int", "mysql_real_escape_string", "ptr", $fd, "ptr", $buffer, "ptr", $queryptr, "int", StringLen($query)+1) ; now, we have the real size, so fix up the data ; I wonder why I have to subtract 1 to get rid of extra stuff at end of string... $bufferfix = DllStructCreate("char[" & ($temp[0]-1) & "]") ; copy string over, which will truncate extra 100 DllStructSetData($bufferfix, 1, DllStructGetData($bufferprep, 1)) However, I am unable to 'process' char** array of strings. Here is what I have tried so far: CODEFunc mysqlFetchRow() Local $temp = DllCall($dll, "ptr", "mysql_fetch_row", "ptr", $res) MsgBox(1, "hmm", $temp[0]) $datastruct = DllStructCreate($temp[0]) ; $temp is char** MsgBox(1, "hmm", DllStructGetData($datastruct, 1)) Local $datatemp = DllStructCreate(DllStructGetData($datastruct, 1)) MsgBox(1, "hmm", DllStructGetData($datatemp, 1)) EndFunc As you can see, I assumed that DllStructGetData would form an array of char* pointers accessible by by DllStructGetData($datastruct, 1-2-3..etc.). But this does not seem to be the case. Any ideas how to implement this? Thanks in advance.
×
×
  • Create New...