//Get delegate that belongs to the api id
        private static T GetApiIdDelegate <T>(NVAPI_Id apiId) where T : class
        {
            try
            {
                IntPtr intPtrApiQuery = IntPtr.Zero;
                if (IntPtr.Size > 4)
                {
                    intPtrApiQuery = NvApiQueryInterface64(apiId);
                }
                else
                {
                    intPtrApiQuery = NvApiQueryInterface32(apiId);
                }

                if (intPtrApiQuery != IntPtr.Zero)
                {
                    return(Marshal.GetDelegateForFunctionPointer(intPtrApiQuery, typeof(T)) as T);
                }
            }
            catch { }
            return(null);
        }
 private static extern IntPtr NvApiQueryInterface32(NVAPI_Id apiId);