以前TurboDelphiを使用していました、以下のソースは通常に動作したのですがDelphi2010にしてからUAの値が最初の一文字のtしか入らなくなりましたどうしてでしょうか?
MessageBoxにはただしくtestuaと表示されます、お手数ですが宜しくお願いします。
var
UserAgent: string;
begin
UserAgent:='testua';
UrlMkSetSessionOption(URLMON_OPTION_USERAGENT, PChar(UserAgent), Length(UserAgent), 0);
MessageBox(Handle, PChar(UserAgent)
end;
Unicodeは受け付けないということでは?
HRESULT UrlMkSetSessionOption(
DWORD dwOption,
__in_bcount_opt(dwBufferLength) LPVOID pBuffer,
DWORD dwBufferLength,
__reserved DWORD dwReserved
);
Parameters
dwOption
[in] An unsigned long integer value that contains the option to set. This can be one of the following values.
INTERNET_OPTION_PROXY
Sets the proxy settings. pBuffer must contain an INTERNET_PROXY_INFO structure. INTERNET_OPTION_PROXY and INTERNET_PROXY_INFO are defined in the Wininet.h file. For more information, see Introduction to the Microsoft Win32 Internet Functions.
INTERNET_OPTION_REFRESH
Sets the value that determines if the proxy information can be reread from the registry. The value TRUE indicates that the proxy information can be reread from the registry. For more information, see Introduction to the Microsoft Win32 Internet Functions.
URLMON_OPTION_USERAGENT
Sets the user agent string for this process.
URLMON_OPTION_USERAGENT_REFRESH
Refreshes the user agent string from the registry for this process.
pBuffer
[in] A pointer to the buffer containing the new session settings.
dwBufferLength
[in] An unsigned long integer value that contains the size of pBuffer.
dwReserved
[in] Reserved. Must be set to 0.
たぶん様
さっそくのご返答ありがとうございます、明記していただいたソースはどの部分に記述すればよろしいでしょうか?いろいろはりつけても構文エラーが・・・
UserAgent: string;を
UserAgent: AnsiString;に
PChar()をPAnsiChar()に
してみては?って事です。
ツイート | ![]() |