首页 > 其他分享 >Delphi打开软键盘osk.exe

Delphi打开软键盘osk.exe

时间:2024-08-07 09:38:37浏览次数:9  
标签:exe end lppe Delphi osk TForm1 软键盘 Font

开发环境Delphi XE11.3

Unit

unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, winapi.ShellAPI, ShlObj, TLHelp32;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

function FindProcess(AFileName:string):boolean;
var
  hSnapshot:THandle;
  lppe:TProcessEntry32;
  Found:Boolean;
begin
  Result:=False;
  hSnapshot:=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
  lppe.dwSize:=SizeOf(TProcessEntry32);
  Found:=Process32First(hSnapshot,lppe);
  while Found do
  begin
    if(lppe.szExeFile = AFileName) then Result:=True;
    Found:=Process32Next(hSnapshot,lppe);
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  vWinDir: array[0..255] of Char;
  vSysDir: array[0..255] of Char;
  vPathStr, vWinDirStr, vSysDirStr: string;
begin
  GetWindowsDirectory(vWinDir, 256);
  GetSystemDirectory(vSysDir, 256);
  vSysDirStr  := StrPas(vSysDir);

  if FileExists(vSysDirStr+'\osk.exe') then
    vPathStr := vSysDirStr+'\osk.exe'
  else
  begin
    vWinDirStr  := StrPas(vWinDir);
    vPathStr := vWinDirStr+'\SysNative\osk.exe';
  end;
  ShellExecute(0, 'open', PChar(vPathStr), nil, nil, SW_SHOWNORMAL);
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  if FindProcess('osk.exe') then
    MessageBox(0, PChar('软键盘已运行'), PChar('提示'), MB_OK);
end;



end.

 

object Form1: TForm1
  Left = 0
  Top = 0
  Caption = 'Form1'
  ClientHeight = 174
  ClientWidth = 308
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -12
  Font.Name = 'Segoe UI'
  Font.Style = []
  Position = poScreenCenter
  TextHeight = 15
  object Button1: TButton
    Left = 104
    Top = 32
    Width = 75
    Height = 25
    Caption = 'Button1'
    TabOrder = 0
    OnClick = Button1Click
  end
  object Button2: TButton
    Left = 104
    Top = 96
    Width = 75
    Height = 25
    Caption = 'Button2'
    TabOrder = 1
    OnClick = Button2Click
  end
end

  

 

 

 

标签:exe,end,lppe,Delphi,osk,TForm1,软键盘,Font
From: https://www.cnblogs.com/dmqhjp/p/18346420

相关文章

  • 【编程语言】Delphi使用教程
    目录一、概述二、Delphi的开发环境三、Delphi基本功能3.1创建新项目3.2设计表单3.3编写代码3.4编译和运行3.5调试四、Delphi的高级的概念和技巧4.1使用组件和类4.2数据库操作4.3图形和多媒体4.4网络编程4.5调试和优化4.6 部署和分发4.7版本控制和......
  • delphi 导出到excel的7种方法
    delphi导出到excel的7种方法本文来自爱好者8888的CSDN博客,全文地址请点击:https://blog.csdn.net/kpc2000/article/details/17066823?utm_source=copy===================================================================================================第一种方法d......
  • Delphi Format 格式化数字
    Format('x=%d',[12]);//'x=12'//最普通Format('x=%3d',[12]);//'x=12'//指定宽度Format('x=%f',[12.0]);//'x=12.00'//浮点数Format('x=%.3f',[12.0]);//'x=12.000'//指定小数Format('x......
  • Delphi 快捷键
    分类快捷键解释备注组件设计类Escape选择当前组件容器 Shift+Click选择多个组件;选择窗体 Tab选择下一个组件 Shift+Tab选择上一个组件 方向键选择此方向的下一个组件 Ctrl+方向键将所选组件的位置移动1个像素 Shift+......
  • Delphi ExtractFilePath
    1、取路径1、取路径。 1.1 ExtractFilePath之类的返回路径。原文链接(https://www.cnblogs.com/ZhouXiHong/archive/2007/01/30/634210.html)ExtractFileDrive:返回完整文件名中的驱动器,如"C:"ExtractFilePath:返回完整文件名中的路径,最后带“/”,如"C:\test\"ExtractFileDir:返......
  • Delphi 线程
    不是原创,只是看到好的内容复制了保存下来,留着学习。 CreadteThred参考,同步参考,WaitForSingleObject参考,互斥参考, 一、在Delphi中使用多线程有两种方法:调用API、使用TThread类;使用API的代码更简单.1、调用API:CreateThread()functionCreateThread( lpThr......
  • DelphiJNI实际调试
    1:下载DelphiJNI:下载地址https://github.com/aleroot/DelphiJNI,版本比较老,没有找到其他,就用这个吧,如朋友有较新的pas文件,请留言下2:下载jdk,这里下载JDK,这里使用javase-jkd18,也不知道这个版本要不要收费,这里学习用暂时不关新这个。3:编写调用class的代码,DelphiJNI没有demo,看代码云......
  • delphi 里的 枚举
    初始值随机若定义一个枚举,他初始化是随机的,并不是第一个元素如:所以若一个类包含了枚举类型,一定要给其赋值,否则就会乱套;枚举不能为nil枚举的零值是随机数字,值类型,不是对象类型;定义时指定数字值//在这个例子中,`cRed`的值是1,`cGreen`的值是2,`cBlue`的值是4。注意,这些......
  • delphi调用Java类
    1、jdk的安装:https://www.cnblogs.com/ljk2008/p/18324820。2、jvm.dll:如果提示找不到JVM.dll需要在classpath、path中分别添加jvm.dll的路径。3、用到三方库:https://github.com/aleroot/DelphiJNI.git。4、JAVA类(CLASS、JAR)要放置在对应的文件夹内,如:packagecom.com1.com2;对......
  • delphi android发送与接收广播
    在Delphi中,可以使用TLocalBroadcastManager类来发送和接收广播。以下是一个示例:发送广播:```delphiuses Androidapi.JNI.GraphicsContentViewText,Androidapi.Helpers,Androidapi.JNI.JavaTypes,Androidapi.JNI.LocalBroadcastManager;procedureSendBroadcast(constAAction:......