我正在尝试使用Indy下载文件,但该文件由PHP脚本提供,因此它没有指定任何Content-Length.因此我无法设置Progressbar.Max.我看到Windows有一些不错的进度条 - 在Delphi中有这样的东西吗?
我想创建一个DLL插件,用于Delphi和其他语言(主要是C++).如何以C++和Delphi友好的方式传递位图?它可以只是Delphi TBitmap的一个句柄吗?C++程序应该能够使用WinApi解码它,对吧?
我需要同时下载文件 - wget不支持,所以我想尝试aria2.但我没有在aria2中看到一个选项来保持目录结构.
当我从命令行运行它时:
7z a 1.zip J:\test.mp4
Run Code Online (Sandbox Code Playgroud)
我可以看到完成了多少百分比。当我尝试使用 CreateProcess 和 CreatePipe 从 Delphi 运行它时,在文件打包之前我什么也没有。然后它显示了 7zip 的最终输出。
我的代码如下所示:
Stream:= THandleStream.Create(hRead);
try
if not CreateProcess(nil, PChar(Cmd), nil, nil,
True, 0, nil, nil, StartupInfo,
ProcessInformation) then
RaiseLastOSError;
repeat
if not GetExitCodeProcess(ProcessInformation.hProcess, ExitCode) then
RaiseLastOSError;
while Stream.Position < Stream.Size do
begin
Stream.Read(C, 1);
if (C = #13) then
begin
Memo1.Lines.Add(S);
S := '';
Application.ProcessMessages;
end
else if C <> #10 then
begin
S := S+C;
end;
end;
until ExitCode <> Still_Active;
finally
Stream.Free;
end;
Run Code Online (Sandbox Code Playgroud)
我不想只创建一个 ZIP …
我有一个文件名中包含非ASCII字母的RAR文件.我尝试用Delphi解码它.我的代码适用于ASCII文件名但在这些上失败了.它不是WideChar,也不是UTF8.我在这里找到了RAR规范:http: //ams.cern.ch/AMS/amsexch/arch/rar/technote.txt 但它没有说明字符编码.我尝试了WOTSIT.org,但是所有RAR链接都已经死了(几乎每个链接都已经死了;我甚至联系了管理员,但他没有回复,也没有修复链接).它似乎不是8位编码,但不知道它是什么.
我尝试过Synapse,Indy和ICS,我对它们并不满意.我想同时下载多个部分的多个文件,支持恢复,gzip编码文件,cookie,使用POST登录网站等等.所以我想我会用套接字写.但我发现Delphi中有很多套接字:TTcpClient,TRawSocket,TCGIRequest,TClientSocket等等.它们都记录错误 - 很难找到用法示例.我尝试使用TTcpClient,但有时程序冻结,然后达到超时,我不知道为什么.在等待回复时看起来像是一个问题.这肯定不是服务器问题,因为我在localhost上测试.使用HTTP协议的最佳套接字是什么?容易使用的东西?
我想在Delphi 7和XE2中使用.我不想使用任何类似WinAPI的东西,所以我不必处理PChars和其他非Delphi的东西.
我想的是:
1)完全符合我的要求 - 在同一文件中使用许多文件的进度条下载多个部分
要么
2)像telnet这样的东西 - 所以我只是把HTTP命令写成字符串,然后得到字节数组,我可以将其转换为字符串或保存到tstream中.
我制作了一个导出多个函数的 DLL(使用 stdcall)。我想让他们中的一些人接受或不接受参数。所以懒惰的程序员可以不带任何参数调用它。我在论坛上的某个地方读到默认参数在 DLL-s 中不起作用。我唯一的选择是创建 2 个具有不同名称的函数,例如:
procedure DoSomething();
begin
DoSomethingParams(1, 'Hi');
end;
procedure DoSomethingParams(one: Integer; two: PChar);
begin
//
end;
Run Code Online (Sandbox Code Playgroud)
? 或者也许有更优雅的方式来实现这一目标?
我试图为短字符串(短于64字节)实现简单的MD5.我正在使用维基百科的算法..一切都编译,但我的结果是字符串:
"hello world"
Run Code Online (Sandbox Code Playgroud)
是:
BB3BB65ED0EE1EE0BB22CB93C3CD5A8F
Run Code Online (Sandbox Code Playgroud)
虽然它应该是:
5EB63BBBE01EEED093CB22BB8F5ACDC3
Run Code Online (Sandbox Code Playgroud)
完整代码在这里:
program Prog;
uses Classes, SysUtils;
function leftrotate(x, c: Cardinal): Cardinal;
begin
leftrotate := (x shl c) or (x shr (32-c));
end;
const s: array[0..63] of Cardinal = (
7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22,
5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20,
4, 11, 16, 23, 4, 11, 16, 23, …Run Code Online (Sandbox Code Playgroud) 我用Delphi 7编写程序。我只需要在非Unicode文件名上工作即可。如果找到Unicode文件名,则应忽略它。
我的代码如下所示:
var Filename: String;
if not FileExists(Filename) then Exit;
F := TFileStream(Filename, fmOpenRead or fmShareDenyWrite);
Run Code Online (Sandbox Code Playgroud)
但是,在某些Unicode文件名的情况下,FileExists()返回true,但随后TFileStream引发异常,因为路径无效。
例如:将名为“ loop ??。jpg”的文件读为“ loop ??。jpg”。这是预期的行为。TFileStream无法读取此类文件(因为目录中没有“ loop ??。jpg”)并引发异常。但是FileExists()应该知道该文件不存在。为什么不起作用?因为它定义为:
function FileExists(const FileName: string): Boolean;
begin
Result := FileAge(FileName) <> -1;
end;
Run Code Online (Sandbox Code Playgroud)
FileAge()定义为:
function FileAge(const FileName: string): Integer;
var
Handle: THandle;
FindData: TWin32FindData;
LocalFileTime: TFileTime;
begin
Handle := FindFirstFile(PChar(FileName), FindData);
...
Run Code Online (Sandbox Code Playgroud)
FindFirstFile使用“ loop .jpg”作为掩码,然后查找“ loop .jpg”。
所以问题很重要:
1)我可以在Delphi 7中以某种方式轻松地在TFileStream中使用Unicode文件名吗?
要么
2)应该使用什么功能代替FileExists以获得正确的结果?
帮助中说“您可以使用 GetIt Package Manager 来发现其他第三方软件并将其安装到 RAD Studio 上。” 但 Indy 在 GetIt 中不可用
我从 Github 下载了最新的文件。我运行 Fullc_Rio.bat 文件,然后打开 Indy260.groupproj 但在编译时我得到:
[Fatal Error] Cannot compile package 'IndySystem260' which is currently required by Delphi 10.3.
Run Code Online (Sandbox Code Playgroud) delphi ×9
dll ×2
aria2 ×1
command-line ×1
delphi-7 ×1
dllexport ×1
file-format ×1
freepascal ×1
http ×1
indy ×1
linux ×1
md5 ×1
pascal ×1
pipe ×1
process ×1
progress-bar ×1
rar ×1
sockets ×1
stdcall ×1
turbo-pascal ×1
unix ×1
visual-c++ ×1