可以判应用程序文件夹下是否有.net环境的文件夹来解决。
Cpp代码
int main(int argc, char* argv[]) { char winDir[256]={0}; GetWindowsDirectory(winDir, 256); //strcat(winDir,"\\Microsoft.Net\\"); printf("%s\n",winDir); //test .net exist. char tcProgramFile[MAX_PATH] = {0}; SHGetSpecialFolderPath(NULL,tcProgramFile,0x26,0); strcat(tcProgramFile,"\\Microsoft.NET"); printf("%s\n",tcProgramFile); HANDLE hFind; WIN32_FIND_DATA FindFileData; hFind = FindFirstFile(tcProgramFile,&FindFileData); if(hFind == INVALID_HANDLE_VALUE) { printf(".Net not exist!\n"); exit(1); } else { printf(".Net environment ok!\n"); } return 0; }