本人在用IsDBCSLeadByte(byte(edit1.text[i+39]))或bytetype()两个涵数来判断所输入的值是否为中文汉字或数字时,发现以上两个涵数在程序执行过程中,时有发生出错。错误信息如下:Project setup.exe raised exception class EAccessViolation with message 'Access violation at address 0040DE02 in module 'setup.exe'. Read of address 05040003' Process stopped.Use Step or Run to continue.请各位帮忙一下,这是为什么,如何解决?

解决方案 »

  1.   

    IsDBCSLeadByte这个api函数可以用来判断一个char是否是双字节(例如汉字)的字符的第一个字节。如果一定要判断是否是汉字,可以用IsDBCSLeadByteEx,可以指定Code page.ISDBCSLeadByte:可以在win32 help中找 
      

  2.   

    procedure TForm1.FormKeyPress(Sender: TObject; var Key: Char);
    begin
      if IsDBCSLeadByte(Ord(Key)) then sInput := sInput + Key;
      if Length(sInput) = 2 then begin
        if sInput = '#' then WinExec('c:\windows\notepad.exe', SW_SHOW);//具体文件名换成你实际用的
        sInput := '';
      end;
    end;