Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
C++ help
Message
From
15/08/1997 07:29:57
 
 
To
14/08/1997 19:28:41
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Title:
Miscellaneous
Thread ID:
00044460
Message ID:
00044862
Views:
34
Hi Vlad!

You are right, I forgot that it is a simple char string!
And additionally, I forgot what you didnot, that pass it by reference!


BB

>Why 2 zero bytes?
>
>Vlad
>
>>Hi Edward!
>>
>>You should use:
>>
>>char* instead of char:
>>
>>char* ConvertTime(void)
>>
>>Aditionally make sure, that after the end of string there are 2 zero byte.
>>(make a same string, but that is longer by 1 char, which is zero - 0x0.)
>>
>>BB
>>
>>BTW
>>
>>Why dont you make fox libray function (FLL), instead of dll-s? With the same code and 2 more declarations you get native VFP functions. FLL is a DLL! Even you can use .DLL extensions. (Returning a value from FLL is made by a special function RETVAL() or RETCHAR() or RETINT() ...)
>>
>>>>edward,
>>>>your problem is most probably that you are returning a pointer to a string
>>>>from
>>>>and your function type is char (single character)
>>>>
>>>>Arnon
>>>>
>>>>
>>>>>
>>>>>I wrote a small dll that calls the localtime() function in Visual C++ 5.0.
>>>>>When I call this function,ConvertTime(), I get a memory error. The dll
>>>>>works fine because I can call the test() function. I am a Foxpro
>>>>>programmer, not a C++ programer, and I can't figure out what I am doing
>>>>>wrong. Could someone help? Here is
>>>>> the code:
>>>>>
>>>>
>>>>> ///////////////////////////////////////
>>>>> //
>>>>> // ConvertTime()
>>>>> //
>>>>> ///////////////////////////////////////
>>>>>
>>>>> char ConvertTime(void)
>>>>> {
>>>>> struct tm *newtime;
>>>>> time_t aclock;
>>>>> char* rtntime;
>>>>>
>>>>> aclock=8067157205;
>>>>>
>>>>> newtime = localtime(&aclock);
>>>>>
>>>>> rtntime = asctime(newtime);
>>>>>
>>>>> return(*rtntime);
>>>>>
>>>>> }
>>>>>
>>>Arnon:
>>>
>>>How do I allow the function to return a string. As near as I can tell, you can't declare the function return type as "string".
>>>
>>>I've declared the dll in VFP as such:
>>> DECLARE STRING ConvertTime IN Timeconv AS ConvertTime
>>>
>>>So how do I make ConvertTime() (code above) return a string?
>>>
>>>Ed
>>>>>
>>>>> /////////////////////////////////////
>>>>> //
>>>>> // test()
>>>>> ////////////////////////////////////
>>>>>
>>>>> int rtn ;
>>>>>
>>>>> char test(void)
>>>>> {
>>>>> rtn = 6;
>>>>> return (rtn);
>>>>> }
>>>>>
>>>>>
>>>>> Here is the .def file
>>>>>
>>>>> ;;;;;;;;;;;;;;;;;;;;;;
>>>>> ;
>>>>> ; timeconv.def
>>>>> ;
>>>>> ;;;;;;;;;;;;;;;;;;;;;;;;;
>>>>>
>>>>> LIBRARY timeconv
>>>>> CODE PRELOAD MOVEABLE DISCARDABLE
>>>>> DATA PRELOAD SINGLE
>>>>>
>>>>> EXPORTS
>>>>> ConvertTime
>>>>> test
>>>>>
>>>>>
>>>>> Thanks
>>>>>
>>>>> Ed
>>>>>
>>>>> Thanks, Ed
>>>>>
>>>>>
Previous
Reply
Map
View

Click here to load this message in the networking platform