delphi7 编译出来的程序 在英文OS会显示??这个程序能够解决。有带源码是VC的。我想转成delphi不成功,谁有空帮我转转,谢谢。
http://www.cnblogs.com/hBifTs/articles/4521.html
VC的
#include "stdafx.h"#pragma comment(linker,"/INCREMENTAL:NO")struct apc_parameter{
 TCHAR x[24];
 LCID local;
 BOOL (WINAPI*SetThreadLocaleA) (LCID Locale);
 int  (WINAPI*MessageBoxA)(HWND hWnd ,LPCSTR lpText,  LPCSTR lpCaption,UINT uType);
};void CALLBACK apc_routine(int _ap)
{
 struct apc_parameter * ap = (struct apc_parameter*)_ap; //  if(!ap->SetThreadLocaleA(LOCALE_SYSTEM_DEFAULT))
 if(!ap->SetThreadLocaleA(ap->local))
 {
 //  ap->MessageBoxA(NULL,ap->x,ap->x,MB_OK);
 }
}int Reverse(LPTSTR filepath)
{
 STARTUPINFO si;
 PROCESS_INFORMATION pi;
 PVOID   codeSeg, dataSeg;
 DWORD   cbWritten;
 struct apc_parameter ap; ZeroMemory(&si, sizeof(si));
 si.cb = sizeof(si); //  TCHAR appPath[] = _T("G:\\Tools\\Network\\QQ\\QQRTF\\QQRTF.exe");
/*  TCHAR *fullPath = GetCommandLine();
 strlwr(fullPath);
 TCHAR par[] = _T("/file:");
 TCHAR *appPath = strstr(fullPath,par);
 if(appPath == NULL)
 {
   return 0;
 }
 appPath += strlen(par);
*/
//  TCHAR appPath[] = _T("D:\\Program Files\\Bradbury\\FeedDemon\\FeedDemon.exe");
 
 CreateProcess(  0,  filepath,  0,  0,  0,  CREATE_SUSPENDED,  0,  0,  &si,  &pi  );
 if(!pi.hThread){
   return -1;
 } //  DWORD codeSize = (DWORD)Func_End - (DWORD)Func_Begin; codeSeg = VirtualAllocEx(pi.hProcess,0,  1024,  MEM_COMMIT,  PAGE_EXECUTE_READWRITE  );
 dataSeg = VirtualAllocEx(pi.hProcess,0,  1024,  MEM_COMMIT,  PAGE_READWRITE  ); ap.local = MAKELCID(MAKELANGID(LANG_CHINESE,SUBLANG_CHINESE_SIMPLIFIED),SORT_CHINESE_PRC);
 strcpy(ap.x,_T("Error")); *((FARPROC*)&ap.SetThreadLocaleA) = GetProcAddress(  GetModuleHandle("kernel32.dll"),  "SetThreadLocale");
//  *((FARPROC*)&ap.MessageBoxA) = GetProcAddress(  GetModuleHandle("user32.dll"),  "MessageBoxA"); WriteProcessMemory(  pi.hProcess,  codeSeg,  apc_routine,  1024,  &cbWritten  ); WriteProcessMemory(  pi.hProcess,  dataSeg,  &ap,  sizeof(ap),  &cbWritten  );
 if(!QueueUserAPC((PAPCFUNC)codeSeg, pi.hThread, (DWORD)dataSeg)){   return -1;
 }
 ResumeThread(pi.hThread);
 CloseHandle(pi.hThread);
 CloseHandle(pi.hProcess);
 return 0;
}
我转的程序:
//----------------
program Project3;
uses
  Windows,SysUtils;type
  apc_parameter=packed record
//    x:array[0..23] of char;
    local:LCID;    p: function (Locale: LCID): BOOL; stdcall;
//    m: function (hWnd: HWND; lpText, lpCaption: PAnsiChar; uType: UINT): Integer; stdcall;
  end;
 procedure apc_routine(_ap:Integer);
 begin
   with apc_parameter(Pointer(_ap)^) do
   begin
//     m(0,x,x,0);
     p(local)
   end
 end; procedure temp ;
 begin
   ;
 end;
//     ap.p(ap.local)
//   if not ap.p(ap.local) then ap.m(0,ap.x,ap.x,0);
  function PatchFile(aFilename:PChar):Boolean;
  var
    vStartupInfo:TStartupInfo;
    vProcessInfo:TProcessInformation;
    vCodeSeg,vDataSeg:Pointer;
    vAp:apc_parameter;
    lpNumberOfBytesWritten: DWORD;
  begin
    FillChar(vStartupInfo,SizeOf(vStartupInfo),#0);
    vStartupInfo.cb:=SizeOf(vStartupInfo);
//    vStartupInfo.dwFlags:=STARTF_USESHOWWINDOW;
//    vStartupInfo.wShowWindow:=SW_SHOWNORMAL;
    if not CreateProcess(nil,aFilename,nil,nil,False,CREATE_SUSPENDED,nil,nil,vStartupInfo,vProcessInfo) then
      Result:=False
    else
    begin
      vCodeSeg := VirtualAllocEx(vProcessInfo.hProcess,nil,1024,MEM_COMMIT,  PAGE_EXECUTE_READWRITE );
       vDataSeg := VirtualAllocEx(vProcessInfo.hProcess,nil,1024,MEM_COMMIT,  PAGE_READWRITE  );
      with vAp do
      begin
        local :=$0804;
//        x :='ERROR';
        @p:=GetProcAddress(GetModuleHandle('kernel32.dll'),'SetThreadLocale');
//        @m:=GetProcAddress(GetModuleHandle('user32.dll'),'MessageBoxA');
      end;       WriteProcessMemory(vProcessInfo.hProcess,vCodeSeg,@apc_routine,Integer(@temp)-Integer(@apc_routine),lpNumberOfBytesWritten);
     WriteProcessMemory(vProcessInfo.hProcess,vDataSeg,@vAp,SizeOf(vAp),lpNumberOfBytesWritten);
     if not (QueueUserAPC(vCodeSeg,vProcessInfo.hThread,DWORD(vDataSeg))) then
      begin
//        MessageBox(0,'','',0);
//        Result :=False;
      end;
      ResumeThread(vProcessInfo.hThread);
      CloseHandle(vProcessInfo.hThread);
      CloseHandle(vProcessInfo.hProcess);
      Result :=True;
    end;
  end;
begin
  PatchFile('c:\1.exe');
  { TODO -oUser -cConsole Main : Insert code here }
end.