For those interested, a relatively clean way to do that is to do it with delay load libraries.
For that you need to add /delayload:nvml.dll to your command line and compile with structured exception (/EHa) ( look at code generation in c/c++ in your project options, it is necessary because the absence of the library ( no cuda installed on the computer ) will result in a C exception ).
then, the loading code is :
LoadLibraryEx("C:\Program Files\NVIDIA Corporation\NVSMI\nvml.dll",NULL,0);
//nvml is disabled
Do not hesitate to contact me if you have questions on this topic.