Home  >  Article  >  Backend Development  >  C++ determines whether the machine has a .Net environment

C++ determines whether the machine has a .Net environment

巴扎黑
巴扎黑Original
2016-12-20 14:35:441575browse

可以判应用程序文件夹下是否有.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;  
}



Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn