請問 DLL 這樣要怎樣傳? |
尚未結案
|
SamSam1230
中階會員 發表:128 回覆:178 積分:65 註冊:2004-12-23 發送簡訊給我 |
|
mustapha.wang
資深會員 發表:89 回覆:409 積分:274 註冊:2002-03-13 發送簡訊給我 |
|
SamSam1230
中階會員 發表:128 回覆:178 積分:65 註冊:2004-12-23 發送簡訊給我 |
|
SamSam1230
中階會員 發表:128 回覆:178 積分:65 註冊:2004-12-23 發送簡訊給我 |
其實我的問題是
我要get system date time format
我是用delphi 4.0 然後發現 SysUtils unit 沒有
procedure GetLocaleFormatSettings ( LCID : Integer; var FormatSettings : TFormatSettings 所以用MFC 去寫一個DLL 給delphi 用 要pass 一條 string , 但C pass string 會 pass string pointer 所以請問delphi 4.0 有GetLocaleFormatSettings 可以call 嗎?
或者是DLL 要pass by ref .string pointer 要怎麼用 謝謝大大
|
mustapha.wang
資深會員 發表:89 回覆:409 積分:274 註冊:2002-03-13 發送簡訊給我 |
当然你不能在dll里写
function getinfo() : ^string;sdtcall;
var
S:string;
begin
....
Result:=@S;
end;
把局部变量返回,因为局部变量离开函数就自动释放了。
1.记得用stdcall
2.让外部传Pchar来比较好
3.SysUtils.LongDateFormat,SysUtils.LongTimeFormat
久病成良医--多试
千人之诺诺,不如一士之谔谔--兼听
發表人 - mustapha.wang 於 2005/03/11 22:57:52
------
江上何人初见月,江月何年初照人 |
SamSam1230
中階會員 發表:128 回覆:178 積分:65 註冊:2004-12-23 發送簡訊給我 |
|
SamSam1230
中階會員 發表:128 回覆:178 積分:65 註冊:2004-12-23 發送簡訊給我 |
引言: 当然你不能在dll里写 function getinfo() : ^string;sdtcall; var S:string; begin .... Result:=@S; end;想請問一下, 你這個dll 裡的function call 的寫法嗎? 已經是這樣的方法寫 另外在主程式裡是這樣call 的 type PString = ^string TDephiGetTimeFormat = function :Pstring; var DephiGetTimeFormat :TDephiGetTimeFormat; begin @DephiGetTimeFormat := GetProcAddress(DLLHandle, 'GetMyTimeFormat'); S := DephiGetTimeFormat^; end;就會有以下的error 請問我是那裡錯呢? 謝謝 |
rexchiu
中階會員 發表:14 回覆:88 積分:70 註冊:2002-03-17 發送簡訊給我 |
插個花...
其實你要的東西..SysUtils.pas中就有了..
以下貼出 help 中的說明
Influence the way numeric or date/time values are formatted. Unit Sysutils The following are a set of variables used to define the format for numeric or date/time strings: var CurrencyString: string; var CurrencyFormat: Byte; var NegCurrFormat: Byte; var ThousandSeparator: Char; var DecimalSeparator: Char; var CurrencyDecimals: Byte; var DateSeparator: Char; var ShortDateFormat: string; var LongDateFormat: string; var TimeSeparator: Char; var TimeAMString: string; var TimePMString: string; var ShortTimeFormat: string; var LongTimeFormat: string; var ShortMonthNames: array[1..12] of string; var LongMonthNames: array[1..12] of string; var ShortDayNames: array[1..7] of string; var LongDayNames: array[1..7] of string; var SysLocale: TSysLocale; var EraNames: array[1..7] of string; var EraYearOffsets: array[1..7] of Integer; var TwoDigitYearCenturyWindow: Word = 50; var TListSeparator: Char; Description The Sysutils unit includes a number of variables that are used by various formatting routines. Values are assigned to these variables to define the formats of numeric and date/time strings. The initial values of these variables are fetched from the system registry using the GetLocaleInfo function in the Win32 API. VCL (non-console) applications automatically update these formatting variables in response to WM_WININICHANGE messages. The Application variable? UpdateFormatSettings method either allows or disallows changes in system settings. The default is True. Set this property to False to prevent the system settings from changing. The description of each variable specifies the LOCALE_XXXX constant used to fetch the initial value using the GetLocaleInfo Win32 API. Typed constant Defines CurrencyString CurrencyString defines the currency symbol (or characters) used in floating-point to decimal conversions. The initial value is fetched from LOCALE_SCURRENCY. CurrencyFormat CurrencyFormat defines the currency symbol placement and separation used in floating-point?o?ecimal conversions. Possible values are: 0 = $1 1 = 1$ 2 = $ 1 3 = 1 $ The initial value is fetched from LOCALE_ICURRENCY. NegCurrFormat NegCurrFormat defines the currency format used in floating-point to decimal conversions of negative numbers. Possible values are: 0 = ($1) 4 = (1$) 8 = -1 $ 12 = $ -1 1 = -$1 5 = -1$ 9 = -$ 1 13 = 1- $ 2 = $-1 6 = 1-$ 10 = 1 $- 14 = ($ 1) 3 = $1- 7 = 1$- 11 = $ 1- 15 = (1 $) The initial value is fetched from LOCALE_INEGCURR. ThousandSeparator ThousandSeparator is the character used to separate thousands in numbers with more than three digits to the left of the decimal separator. The initial value is fetched from LOCALE_STHOUSAND. DecimalSeparator DecimalSeparator is the character used to separate the integer part from the fractional part of a number. The initial value is fetched from LOCALE_SDECIMAL. CurrencyDecimals CurrencyDecimals is the number of digits to the right of the decimal point in a currency amount. The initial value is fetched from LOCALE_ICURRDIGITS. DateSeparator DateSeparator is the character used to separate the year, month, and day parts of a date value. The initial value is fetched from LOCATE_SDATE. ShortDateFormat ShortDateFormat is the format string used to convert a date value to a short string suitable for editing. For a complete description of date and time format strings, see the documentation for the FormatDateTime function. The short date format should only use the date separator character and the m, mm, d, dd, yy, and yyyy format specifiers. The initial value is fetched from LOCALE_SSHORTDATE.. LongDateFormat LongDateFormat is the format string used to convert a date value to a long string suitable for display but not for editing. For a complete description of date and time format strings, see the documentation for the FormatDateTime function. The initial value is fetched from LOCALE_SLONGDATE. TimeSeparator TimeSeparator is the character used to separate the hour, minute, and second parts of a time value. The initial value is fetched from LOCALE_STIME. TimeAMString TimeAMString is the suffix string used for time values between 00:00 and 11:59 in 12-hour clock format. The initial value is fetched from LOCALE_S1159. TimePMString TimePMString is the suffix string used for time values between 12:00 and 23:59 in 12-hour clock format. The initial value is fetched from LOCALE_S2359. ShortTimeFormat ShortTimeFormat is the format string used to convert a time value to a short string with only hours and minutes. The default value is computed from LOCALE_ITIME and LOCALE_ITLZERO. LongTimeFormat LongTimeFormat is the format string used to convert a time value to a long string with hours, minutes, and seconds. The default value is computed from LOCALE_ITIME and LOCALE_ITLZERO. ShortMonthNames ShortMonthNames is the array of strings containing short month names. The mmm format specifier in a format string passed to FormatDateTime causes a short month name to be substituted. The default values are fetched from the LOCALE_SABBREVMONTHNAME system locale entries. LongMonthNames LongMonthNames is the array of strings containing long month names. The mmmm format specifier in a format string passed to FormatDateTime causes a long month name to be substituted. The default values are fetched from the LOCALE_SMONTHNAME system locale entries. ShortDayNames ShortDayNames is the array of strings containing short day names. The ddd format specifier in a format string passed to FormatDateTime causes a short day name to be substituted. The default values are fetched from the LOCALE_SABBREVDAYNAME system locale entries. LongDayNames LongDayNames is the array of strings containing long day names. The dddd format specifier in a format string passed to FormatDateTime causes a long day name to be substituted. The default values are fetched from the LOCALE_SDAYNAME system locale entries. SysLocale Indicates the locale used by FormatDateTime to interpret dates. EraName Controls the DateTimeToStr function (for East Asian locales). EraYearOffsets Controls the DateTimeToStr function (for East Asian locales). TwoDigitYearCenturyWindow Determines what century is added to two-digit years when string dates are converted to numeric dates with StrToDate or StrToDateTime. The value of TwoDigitYearCenturyWindow, if it is nonzero, is subtracted from the current year to calculate the floating ?ivot?prior to which two-digit years are interpreted as falling in the next century. The default value is 50. You can use TwoDigitYearCenturyWindow to extend the life of legacy applications that are tied to two-digit-year data entry; but the best solution is to require four-digit input for years. ListSeparator The character used to separate items in a list. The default value is fetched from LOCALE_SLIST.這樣好像不好看,去查delphi的help 中有關Currency and date/time formatting variables就是了. 以你要的東西你只要直接去取得 ShortDateFormat,LongDateFormat,ShortTimeFormat,LongTimeFormat 這幾個字串就是了
------
Best Regards, Rex Chiu |
SamSam1230
中階會員 發表:128 回覆:178 積分:65 註冊:2004-12-23 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |