我有一个delphi控制台应用程序,我需要在用户按任意键时终止,问题是我不知道如何实现一个功能来检测按键何时,我想这样做.
{$APPTYPE CONSOLE}
begin
MyTask:=MyTask.Create;
try
MyTask.RunIt;
while MyTask.Running and not IsKeyPressed do //how i can implement a IsKeyPressed function?
MyTask.SendSignal($56100AA);
finally
MyTask.Stop;
MyTask.Free;
end;
Run Code Online (Sandbox Code Playgroud)
结束.
我知道哪个使用GetForegroundWindow函数我可以获得当前活动窗口句柄,但现在i want to detect when the active window (of any application) changes (become active).我想到的第一个解决方案是
我想知道是否存在更好的方法来执行此操作可能使用Windows消息或其他东西.
在下载之前,如何使用Delphi确定Web中托管的远程文件的大小(以字节为单位)?
提前致谢.
如果Delphi是我开发的主要语言,那么Delphi的理想补充是什么.这应该是我的下一步?
你有什么建议?
如何在执行.Net应用程序期间始终保持SqlConnection(或使用其他组件)打开(连接)?
我需要这个,因为我的应用程序需要使用此commnad进行检测
exec sp_who2
Run Code Online (Sandbox Code Playgroud)
我的应用程序的多少个实例连接到mydatabase,以限制访问(许可证控制).
例
A)我的应用程序从location1执行
exec sp_who2 B)我的应用程序从location2执行
exec sp_who2 对不起我的英语不好.
提前致谢.
我需要在查询执行之前显示一个弹出窗口,显示执行sql查询时经过的时间,并在查询结束时关闭该窗口.
其实我做的是这样的
var
frm : tFrmPopupElapsed;
// this form has a TTimer and a TLabel to show the elapsed time
// but the label is not updated, I tried using update and refresh
// but nothing happens
begin
frm := tFrmPopupElapsed.Create(nil);
try
frm.Init; // this procedure enables the timer
frm.Show();
ExecuteMyVeryLongQuery();
finally
frm.Close;
end;
end;
Run Code Online (Sandbox Code Playgroud)
如何更新标签以显示查询执行时所用的时间?使用计时器?还是线程?
考虑下一个示例应用程序
program TestMemory;
{$APPTYPE CONSOLE}
uses
PsAPI,
Windows,
SysUtils;
function GetUsedMemoryFastMem: cardinal;
var
st: TMemoryManagerState;
sb: TSmallBlockTypeState;
begin
GetMemoryManagerState(st);
result := st.TotalAllocatedMediumBlockSize + st.TotalAllocatedLargeBlockSize;
for sb in st.SmallBlockTypeStates do
begin
result := result + sb.UseableBlockSize * sb.AllocatedBlockCount;
end;
end;
function GetUsedMemoryWindows: longint;
var
ProcessMemoryCounters: TProcessMemoryCounters;
begin
Result:=0;
ProcessMemoryCounters.cb := SizeOf(TProcessMemoryCounters);
if GetProcessMemoryInfo(GetCurrentProcess(), @ProcessMemoryCounters, ProcessMemoryCounters.cb) then
Result:= ProcessMemoryCounters.WorkingSetSize
else
RaiseLastOSError;
end;
procedure Test;
const
Size = 1024*1024;
var
P : Pointer;
begin
GetMem(P,Size);
Writeln('Inside');
Writeln('FastMem '+FormatFloat('#,', GetUsedMemoryFastMem));
Writeln('Windows '+FormatFloat('#,', GetUsedMemoryWindows));
Writeln(''); …Run Code Online (Sandbox Code Playgroud) 我正在使用这个代码做一个透明的纯色形式.
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
procedure WMNCHitTest(var Message: TWMNCHitTest); message WM_NCHITTEST;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
var
BlendFunction: TBlendFunction;
BitmapPos: TPoint;
BitmapSize: TSize;
exStyle: DWORD;
Bitmap: TBitmap;
begin
exStyle := GetWindowLongA(Handle, GWL_EXSTYLE);
if (exStyle and WS_EX_LAYERED = 0) then
SetWindowLong(Handle, GWL_EXSTYLE, exStyle or WS_EX_LAYERED);
Bitmap := TBitmap.Create;
try
Bitmap.PixelFormat …Run Code Online (Sandbox Code Playgroud) 我正在使用TIdHTTPServer组件,到目前为止工作正常,但是当我使用此代码添加SSL支持时
SSLHandler:= TIdServerIOHandlerSSLOpenSSL.Create(nil);
SSLHandler.SSLOptions.CertFile := 'foo.pem';
SSLHandler.SSLOptions.KeyFile := 'foo.pem';
SSLHandler.SSLOptions.RootCertFile := 'foo.pem';
SSLHandler.SSLOptions.Method := sslvSSLv23;
SSLHandler.SSLOptions.Mode := sslmServer;
SSLHandler.SSLOptions.VerifyDepth := 1;
SSLHandler.SSLOptions.VerifyMode := [sslvrfPeer,sslvrfFailIfNoPeerCert,sslvrfClientOnce];
idHttpServer1.IOHandler := SSLHandler;
IdHTTPServer1.Bindings.Add.Port := 80;
IdHTTPServer1.Bindings.Add.Port := 443;
IdHTTPServer1.Active := True;
Run Code Online (Sandbox Code Playgroud)
服务器只处理https请求,如果我发送http请求,则抛出此异常
Error accepting connection with SSL. error:1407609C:SSL routines:SSL23_GET_CLIENT_HELLO:http request
问题是:我可以使用单个TIdHTTPServer组件来处理http和https请求吗?如果答案是肯定如何做到这一点?如果答案为否,我必须创建两个TIdHTTPServer实例,一个用于http,另一个用于https?
我正在使用像这样的脚本构建我的Delphi应用程序
call "C:\Program Files (x86)\Embarcadero\RAD Studio\11.0\bin\rsvars.bat"
msbuild.exe "C:\Projects\Foo\Bar.dproj"
Run Code Online (Sandbox Code Playgroud)
现在我想添加一个选项将应用程序部署到OSX(或IOS)系统修改这样的脚本,那么可以从命令行部署OSX或IOS Delphi项目吗?
delphi ×9
winapi ×2
ado.net ×1
c# ×1
delphi-2007 ×1
delphi-7 ×1
delphi-xe4 ×1
http ×1
indy ×1
winforms ×1