2016-08-18 59 views

回答

3

使用INT 21h, AX=6501h。這裏是Turbo C的代碼:

#include <dos.h> 
#include <stdio.h> 

struct country_info_buffer 
{ 
    unsigned char info_id; 
    unsigned short buffer_size; 
    unsigned short country_id; 
    unsigned short code_page; 
    struct COUNTRY country_info; 
}; 

int main() 
{ 
    /* Registers for INT21 call */ 
    union REGS regs; 
    struct SREGS sregs; 
    /* Output buffer */ 
    struct country_info_buffer info; 

    /* Get current value of segment registers */ 
    segread(&sregs); 

    /* Get extended country information/general internationalization info */ 
    regs.x.ax = 0x6501; 
    /* Global code page */ 
    regs.x.bx = 0xFFFF; 
    /* Current country */ 
    regs.x.dx = 0xFFFF; 
    /* Size of output buffer */ 
    regs.x.cx = sizeof(info); 
    /* Pointer to output buffer goes to ES:DI */ 
    sregs.es = FP_SEG(&info); 
    regs.x.di = FP_OFF(&info); 

    /* Call int21 */ 
    intdosx(&regs, &regs, &sregs); 

    if (regs.x.cflag) 
    { 
    printf("Call failed, ax=%d\n", regs.x.ax); 
    return 1; 
    } 
    printf("Country code: %d, Code page: %d\n", info.country_id, info.code_page); 
    return 0; 
} 

Btw。 Ralf Brown的中斷列表是DOS系統調用的好資源。太糟糕了,甚至在DOS退出之前就停止了維護,所以一些「最新」的東西不在那裏描述。

+0

優秀的答案。不幸的是,DOSBox似乎沒有提供有用的國家或代碼頁信息。返回的信息是1 + 437(美國國家和代碼頁)。當前的鍵盤佈局可能是檢測國家唯一有用的來源。 – digitalfootmark