我用的是xp
Option ExplicitPrivate Declare Function GetSystemDirectory Lib "kernel32" Alias _
    "GetSystemDirectoryA" (ByVal lpBuffer As String, _
    ByVal nSize As Long) As Long
Private Sub Command1_Click()
Dim sysDir As String
sysDir = Space$(260)
GetSystemDirectory sysDir, Len(sysDir)
sysDir = Left$(sysDir, InStr(sysDir & vbNullChar, vbNullChar) - 1)
Debug.Print sysDir
End Sub
void CADlg::OnButton2() 
{
// TODO: Add your control notification handler code here
char c[ 100 ];
//GetDlgItem( IDC_IPADDRESS1 )->GetWindowText( c, 100 );
//AfxMessageBox( c, MB_OK, -1 );
//sprintf( c, "%x", WM_CTLCOLORDLG );
//AfxMessageBox( c, MB_OK, -1 );
GetSystemDirectory( c, 100 );
AfxMessageBox( c );
}结果一样