gpt4 book ai didi

delphi - 将 Delphi Indy v9 代码转换为 v10

转载 作者:行者123 更新时间:2023-12-01 21:48:52 25 4
gpt4 key购买 nike

我在使用下面引用 StoredPathName 的代码时遇到问题。由于 Indy 10 不使用 StoredPathName,我不确定如何更改此代码以从 V9 调整到 V10。下面的代码不是我编写的,而且对于此类代码我仍然是新手,因此我希望有一个代码示例来展示如何在可能的情况下纠正问题。

vlist:TStringList;

...
for j:=numEmails downto 1 do
begin
Msg.Clear;
Retrieve(j,Msg);

for k:=0 to Msg.MessageParts.Count-1 do
with Msg.MessageParts[k] do
if Msg.messageParts[k] is TIdAttachmentFile then
begin
//Get the name of the file that was sent.
aname := TIdAttachmentFile(Msg.MessageParts[k]).FileName;

if SameText(aname,ExtractFilename(PacketFilename))
and FileExists(Longfilename(StoredPathName)) then
begin
//Read attachment and do call-back if defined.
vlist.LoadfromFile(LongFilename(StoredPathName));

if assigned(OnReceive) then
OnReceive;
end
end;
end;

Disconnect;

except
on E:Exception do
result := E.Message;
end;

另外一段代码是... Connect(9000);由于 9000 不是一个允许的参数,我只是将其更改为 Connect; 可以吗?

最佳答案

StoredPathName 是从 TIdMessagePart 移至 TIdAttachmentFile 的属性。如果您更改代码以在顶部进行类型转换,那么它应该可以正常工作。

更改此:

  with Msg.MessageParts[k] do
if Msg.messageParts[k] is TIdAttachmentFile then

至:

  if Msg.messageParts[k] is TIdAttachmentFile then
with TIdAttachmentFile(Msg.MessageParts[k]) do

关于delphi - 将 Delphi Indy v9 代码转换为 v10,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11312457/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com