BOOL WINAPI ImmSetHotKey(    //设置输入法的热键
                DWORD dwHotKeyID,
                UINT uModifiers,
                UINT uVKey,
                hKL hKL
            )
请问输入法 API 函数 immsethotkey 到底该怎样使用呢?我试用 immgethotkey 函数取得了 uModifiers、uVKey、hKL 等数据后直接再写回去,函数虽能正常执行,结果却是错的,在注册表中生成的值完全不对。unit Unit1;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs;type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;var
  Form1: TForm1;implementation{$R *.dfm}
function ImmGetHotKey(dwHotKeyID: DWord; var uModifiers: UINT; var uVKey: UINT; var hKL: HKL): Boolean; stdcall; external 'Imm32.dll' Name 'ImmGetHotKey';
function ImmSetHotKey(dwHotKeyID: DWord; var uModifiers: UINT; var uVKey: UINT; var hKL: HKL): Boolean; stdcall; external 'Imm32.dll' Name 'ImmSetHotKey';
procedure TForm1.FormCreate(Sender: TObject);
var
uModifiers,uVKey: UINT;
ime: HKL;
begin
 immgethotkey($100,uModifiers,uVKey,ime);
 immsethotkey($100,uModifiers,uVKey,ime);
end;
end.此段程序取注册表的热键数据,例如:
[HKEY_CURRENT_USER\Control Panel\Input Method\Hot Keys\00000100]
"Virtual Key"=hex:31,00,00,00
"Key Modifiers"=hex:06,c0,00,00
"Target IME"=hex:04,08,0e,e0
然后再直接写回去,然而结果却变成了:
[HKEY_CURRENT_USER\Control Panel\Input Method\Hot Keys\00000100]
"Virtual Key"=hex:18,fe,12,00
"Key Modifiers"=hex:14,fe,12,00
"Target IME"=hex:1c,fe,12,00请问错在哪里,应该如何做呢?

解决方案 »

  1.   

    我试了一试,immgethotkey还可以,到immsethotkey就出现错误了,很奇怪
      

  2.   

    o~~ 具体错误呢
    这个函数 没用过哦 再MSDN怎么查不到??
      

  3.   

    The ImmSimulateHotKey function simulates the specified IME hot key, causing the same response as if the user had pressed the hot key in the specified window.BOOL ImmSimulateHotKey(    HWND hWnd, 
        DWORD dwHotKeyID
       );
     ParametershWndHandle to the window.dwHotKeyIDIdentifier of the IME hot key. Can be one of the values specified in the "IME Hot Key Identifiers" table in Input Method Editor Constants. Return ValuesIf the function succeeds, the return value is a nonzero value.
    If the function fails, the return value is zero.
      

  4.   

    Requirements
    OS Versions: Windows CE .NET 4.0 and later.
    Header: Imm.h.
    Link Library: Coreimm.lib.
      

  5.   

    98下运行正常?难说,我觉得2000总比98版本高吧,而且在delphi6的帮助里面都找不到,我觉得可能的更新sdk,好像天机论坛vc版的版主说过,sdk要更新的问题
      

  6.   

    ft,朋友的测试结果有误,98也运行也有些问题,但不会生成错误的键值。
    此函数在 MSDN 上说明是支持 windows CE 的,但在一些介绍输入法的网站上介绍说普通 windows 也可用。
    那么 windows 本身设置输入法时到底是用了什么函数呢?