windows API要加::
char dir[512];
     UINT dirlen;
     ::GetSystemDirectory[dir,MAX_PATH]; 

解决方案 »

  1.   

    code_man说的不太对……原因是:GetSystemDirectory是一个函数,
    而C/C++函数调用应该使用(),而不是[]。
    所以,这样就对了:
    char dir[512];
         UINT dirlen;
         GetSystemDirectory(dir,MAX_PATH);^_^
      

  2.   

    :(
    出现这个错误:
    error C2664: 'GetSystemDirectoryW' : cannot convert parameter 1 from 'char [512]' to 'unsigned short *'
            Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
    Error executing cl.exe.
      

  3.   

    这是因为你打开了Unicode,
    关了就可以了。如果确是有必要使用Unicode的话,
    就不应该使用char,
    应该使用wchar_t(这也是标准C++的呦!)