Delphi2010にしてからの不具合


しんご  2010-11-09 08:03:17  No: 39507

以前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;


たぶん  2010-11-09 09:49:58  No: 39508

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.


しんご  2010-11-09 10:31:50  No: 39509

たぶん様
さっそくのご返答ありがとうございます、明記していただいたソースはどの部分に記述すればよろしいでしょうか?いろいろはりつけても構文エラーが・・・


monaa  2010-11-09 11:09:07  No: 39510

UserAgent: string;を
UserAgent: AnsiString;に

PChar()をPAnsiChar()に
してみては?って事です。


※返信する前に利用規約をご確認ください。

※Google reCAPTCHA認証からCloudflare Turnstile認証へ変更しました。






  このエントリーをはてなブックマークに追加