Projekt NVIDIA

Post a reply


In an effort to prevent automatic submissions, we require that you complete the following challenge.
Smilies
:D :) ;) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :!: :?: :idea: :| :mrgreen: :geek: :ugeek: :arrow: :angel: :clap: :crazy: :eh: :lolno: :problem: :shh: :shifty: :sick: :silent: :think: :thumbup: :thumbdown: :salute: :wave: :wtf: :yawn: :facepalm: :bravo: :dance: :beard: :morebeard: :xmas: :HeHe: :trollface: :cookie: :rainbow: :monkeysee: :monkeysay: :happybday: :headwall: :offtopic: :superhappy: :terms: :beer:
View more smilies

BBCode is ON
[img] is OFF
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Projekt NVIDIA

Re: Projekt NVIDIA

Post by just me » 25 Dec 2014, 06:49

Na ja, wenn bei Dir alle Displays 'attached' sind, findet er eben keine 'unattachten'. :xmas:

Re: Projekt NVIDIA

Post by jNizM » 25 Dec 2014, 06:38

Danke für den Tipp
UInt* in EnumNvidiaDisplayHandle() hat das Problem beseitigt.

Nur EnumNvidiaUnAttachedDisplayHandle() gibt noch -7 in 32 und 64 bit und dementsprechend gibt GetUnAttachedAssociatedDisplayName() -5 (abhängigkeit)

Re: Projekt NVIDIA

Post by just me » 25 Dec 2014, 02:32

Guten Morgen,
just me wrote:Das klappt allerdings mit 64-Bit - wie schon gesagt - nur dann, wenn ich als Typ für DispHandle in EnumNvidiaUnAttachedDisplayHandle() entweder UIntP, PtrP oder UPtrP bzw. ihre * Equivalente wähle.
Hast Du das für EnumNvidiaDisplayHandle() auch schon versucht? Du benutzt ja in GetAssociatedNvidiaDisplayName() für NvDispHandle den Typ Ptr. D.h., für ein 'negatives' Handle wie -570425343 wird der Wert in seiner vollen Länge von 8-Byte als FFFFFFFFDE000001 übergeben, während die 32-Bit Version davon nur den Teil DE000001 zu sehen bekommt. Ich weiß nicht, ob das im Sinne der NvAPI ist.

Re: Projekt NVIDIA

Post by jNizM » 24 Dec 2014, 10:03

Auch dir Frohe Weihnachten

Installiert ist AutoHotkey als x64 auf Win 7 x64

Sysget, MonName, MonitorName gibt mir \\.\DISPLAY1 zurück
Sysget, MonName2, MonitorName, 2 gibt mir \\.\DISPLAY2 zurück

EnumNvidiaDisplayHandle() gibt mir nur für 0 & 1 Handles zurück, alles danach ist -7
GetAssociatedNvidiaDisplayName() gibt mir -6
EnumNvidiaUnAttachedDisplayHandle() gibt mir immer -7 zurück

mit GetAssociatedNvidiaDisplayHandle() sowie "\\.\DISPLAY1" und "\\.\DISPLAY2" lässt sich DVC verändern


==============================

Wenn ich die exe in x86 compiliere bekomme ich bei GetAssociatedNvidiaDisplayName() \\.\DISPLAY1 zurück

Code: Select all

GetAssociatedNvidiaDisplayName(thisEnum := 0)
{
    NvDispHandle := NvAPI.EnumNvidiaDisplayHandle(thisEnum)
    VarSetCapacity(szDisplayName, NvAPI.NVAPI_SHORT_STRING_MAX, 0)
    if !(NvStatus := DllCall(NvAPI._GetAssociatedNvidiaDisplayName, "Ptr", NvDispHandle, "Ptr", &szDisplayName, "CDECL"))
        return StrGet(&szDisplayName, "CP0")
    return "*" NvStatus
}
Da ist wohl n Fehler im Code der für x86 aber nicht für x64 funktioniert

Re: Projekt NVIDIA

Post by just me » 24 Dec 2014, 03:13

Frohe Weihnachten!

Gut, das heißt, Dein Windows ist der Meinung, dass der primäre Monitor (Flags: ATTACHED_TO_DESKTOP + PRIMARY_DEVICE) den Namen \\.\DISPLAY4 und der zweite Monitor (Flags: ATTACHED_TO_DESKTOP ) den Namen \\.\DISPLAY5 hat. Dann sollte auch SysGet, MonName, MonitorName den Namen \\.\DISPLAY4 liefern. Die anderen Devices sind virtuell und gehören zu RDP (Flags: TS_COMPATIBLE + MIRRORING_DRIVER).

Nun die spannenden Fragen:
1. Nutzt Du z.Zt. eine 32-Bit oder eine 64-Bit Version?
2. Wenn Du EnumNvidiaDisplayHandle() in einer Schleife mit inkrementellem Index laufen lässt, wie viele Handles werden dann ausgegeben, bevor der Status NVAPI_END_ENUMERATION (-7) zurückgegeben wird.
3. Warum weigert sich GetAssociatedNvidiaDisplayName(), für diese Handles einen Namen zu liefern?

Re: Projekt NVIDIA

Post by jNizM » 23 Dec 2014, 18:53

Code: Select all

Name: \\.\DISPLAY4
String: NVIDIA GeForce GTX 580
ID: PCI\VEN_10DE&DEV_1080&SUBSYS_086A196E&REV_A1
Key: \Registry\Machine\System\CurrentControlSet\Control\Video\{EF8364E1-98BE-4EC3-A36B-F6CA6B94F3C1}\0000
Flags: 5

Code: Select all

Name: \\.\DISPLAY5
String: NVIDIA GeForce GTX 580
ID: PCI\VEN_10DE&DEV_1080&SUBSYS_086A196E&REV_A1
Key: \Registry\Machine\System\CurrentControlSet\Control\Video\{EF8364E1-98BE-4EC3-A36B-F6CA6B94F3C1}\0001
Flags: 1

Code: Select all

Name: \\.\DISPLAYV1
String: RDPDD Chained DD
ID: 
Key: \Registry\Machine\System\CurrentControlSet\Control\Video\{DEB039CC-B704-4F53-B43E-9DD4432FA2E9}\0000
Flags: 2097160

Code: Select all

Name: \\.\DISPLAYV2
String: RDP Encoder Mirror Driver
ID: 
Key: \Registry\Machine\System\CurrentControlSet\Control\Video\{42cf9257-1d96-4c9d-87f3-0d8e74595f78}\0000
Flags: 2097160

Code: Select all

Name: \\.\DISPLAYV3
String: RDP Reflector Display Driver
ID: 
Key: \Registry\Machine\System\CurrentControlSet\Control\Video\{b043b95c-5670-4f10-b934-8ed0c8eb59a8}\0000
Flags: 2097160

Re: Projekt NVIDIA

Post by just me » 23 Dec 2014, 16:46

Das ist witzig (oder auch nicht). Wenn Du Dir das mal als Hexwert anschaust, liefert

-570425343 -> FFFFFFFF DE000001 und
-570425342 -> FFFFFFFF DE000002.

Ich habe einen Onboard Intel-Grafikchip und zusätzlich einen NVIDIA Chip, der nur mit einem Ausgang verbunden ist. Der Ausgang für den Intel-Chip und das Notebookdisplay, das auch am Intel-Chip hängt, liefern natürlich nichts bzw. -6. Der Ausgang für die NVIDIA-Grafik, der nicht mit einem Monitor verbunden ist, liefert allerdings für EnumNvidiaUnAttachedDisplayHandle()
FFFFFFFF CC000003,
und für GetUnAttachedAssociatedDisplayName()
\\.\DISPLAY3.
Das klappt allerdings mit 64-Bit - wie schon gesagt - nur dann, wenn ich als Typ für DispHandle in EnumNvidiaUnAttachedDisplayHandle() entweder UIntP, PtrP oder UPtrP bzw. ihre * Equivalente wähle. Warum Dir für GetAssociatedNvidiaDisplayName() -6 geliefert wird, verstehe ich nicht.

Lass doch das mal bei Dir laufen:

Code: Select all

; ======================================================================================================================
; Namespace:         Display_EnumDevices()
; Function:          Retrieves information about the display devices in the current session.
; AHK version:       AHK 1.1.+ (required)
; Language:          English
; Tested on:         Win 7 x64/U64
; Version:           1.0.00.00/2013-07-20/just me
; MSDN:              http://msdn.microsoft.com/en-us/library/dd162609(v=vs.85).aspx
; ======================================================================================================================
; This software is provided 'as-is', without any express or implied warranty.
; In no event will the authors be held liable for any damages arising from the use of this software.
; ======================================================================================================================
; ======================================================================================================================
Display_EnumDevices() {
   ; ===================================================================================================================
   ; MS constants
   ; Flags:
   ; ATTACHED_TO_DESKTOP = 0x00000001
   ; DISCONNECT          = 0x02000000
   ; MIRRORING_DRIVER    = 0x00000008
   ; MODESPRUNED         = 0x08000000
   ; MULTI_DRIVER        = 0x00000002
   ; PRIMARY_DEVICE      = 0x00000004
   ; REMOTE              = 0x04000000
   ; REMOVABLE           = 0x00000020
   ; TS_COMPATIBLE       = 0x00200000
   ; UNSAFE_MODES_ON     = 0x00080000 ; Vista+
   ; VGA_COMPATIBLE      = 0x00000010
   ; ===================================================================================================================
   ; AHK constants
   ; DISPLAY_DEVICE structure -> http://msdn.microsoft.com/en-us/library/dd183569(v=vs.85).aspx
   Static cbTCHAR := A_IsUnicode? 2 : 1
   Static cbDISPDEV := 4 + 4 + ((32 + 128 + 128 + 128) * cbTCHAR)
   Static offName := 4
   Static offString := offName + (32 * cbTCHAR)
   Static offFlags := offString + (128 * cbTCHAR)
   Static offID := offFlags + 4
   Static offKey := offID + (128 * cbTCHAR)
   ; ===================================================================================================================
   ; Create the DISPLAY_DEVICE structure
   VarSetCapacity(DD, cbDISPDEV, 0)
   NumPut(cbDISPDEV, DD, 0, "UInt")
   Devices := []
   While DllCall("User32.dll\EnumDisplayDevices", "Ptr", 0, "UInt", A_Index - 1, "Ptr", &DD, "UInt", 0, "UInt") {
      Devices.Insert({Name:   StrGet(&DD + offName, 32)
                    , String: StrGet(&DD + offString, 128)
                    , ID:     StrGet(&DD + offID, 128)
                    , Key:    StrGet(&DD + offKey, 128)
                    , Flags:  NumGet(DD, offFlags, "UInt")})
      VarSetCapacity(DD, cbDISPDEV, 0)
      NumPut(cbDISPDEV, DD, 0, "UInt")
   }
   Return Devices
}
; ======================================================================================================================
; Sample code
#NoEnv
SetBatchLines, -1
DisplayDevices := Display_EnumDevices()
For I, Device In DisplayDevices {
   Msg := ""
   Msg .= "Name: " . Device.Name . "`r`n"
   Msg .= "String: " . Device.String . "`r`n"
   Msg .= "ID: " . Device.ID . "`r`n"
   Msg .= "Key: " . Device.Key . "`r`n"
   Msg .= "Flags: " . Device.Flags
   MsgBox, 0, Device #I, %Msg%
}
ExitApp
; ======================================================================================================================
Welcher Grafikchip wird bei Dir ausgegeben?

Re: Projekt NVIDIA

Post by jNizM » 23 Dec 2014, 12:29

Na klar: (2 Monitore)

NVIDIA.EnumNvidiaDisplayHandle(0) ==> -570425343
NVIDIA.EnumNvidiaDisplayHandle(1) ==> -570425342

Re: Projekt NVIDIA

Post by just me » 23 Dec 2014, 10:00

Hallo, kannst Du mir mal zeigen, welche Werte bei Dir EnumNvidiaDisplayHandle() liefert?

Re: Projekt NVIDIA

Post by jNizM » 23 Dec 2014, 06:37

Bei EnumNvidiaUnAttachedDisplayHandle bekomm ich nur -7 raus
NVAPI_END_ENUMERATION = -7, //!< No more items to enumerate

Re: Projekt NVIDIA

Post by just me » 23 Dec 2014, 06:10

Witzig (oder auch nicht). Das da liefert mir den Namen des bei mir nicht vorhandenen \\.\DISPLAY3:

Code: Select all

            NvAPI._EnumNvidiaUnAttachedDisplayHandle         := DllCall(NvAPI.DllFile "\nvapi_QueryInterface", "UInt", 0x20DE9260, "CDECL UPtr")
            NvAPI._GetUnAttachedAssociatedDisplayName        := DllCall(NvAPI.DllFile "\nvapi_QueryInterface", "UInt", 0x4888D790, "CDECL UPtr")
...
    EnumNvidiaUnAttachedDisplayHandle(Index := 0) {
        If (NvStatus := DllCall(NvAPI._EnumNvidiaUnAttachedDisplayHandle, "Int", Index, "UIntP", DispHandle, "CDECL")) = 0 {
            Return DispHandle
        }
        ErrorLevel := NvStatus
        Return False
    }
...
    GetUnAttachedAssociatedDisplayName()
    {
         Static NVAPI_SHORT_STRING_MAX := 64
         NvDispHandle := NvAPI.EnumNvidiaUnAttachedDisplayHandle()
         VarSetCapacity(szDisplayName, NVAPI_SHORT_STRING_MAX, 0)
         if !(NvStatus := DllCall(NvAPI._GetUnAttachedAssociatedDisplayName, "Int", NvDispHandle, "Ptr", &szDisplayName, "CDECL"))
             return StrGet(&szDisplayName, "CP0")
         return "*" NvStatus
    }
Allerdings nur dann, wenn ich als Typ für DispHandle in EnumNvidiaUnAttachedDisplayHandle() UIntP verwende.

Re: Projekt NVIDIA

Post by jNizM » 23 Dec 2014, 05:13

mit Astr gings

Code: Select all

GetAssociatedNvidiaDisplayHandle(szDisplayName := "\\.\DISPLAY1")
{
    if !(NvStatus := DllCall(NvAPI._GetAssociatedNvidiaDisplayHandle, "AStr", szDisplayName, "Int*", pNvDispHandle, "CDECL"))
        return pNvDispHandle
    return "*" NvStatus
}

NVIDIA.GetAssociatedNvidiaDisplayHandle("\\.\DISPLAY1")    ; ==> -570425343
NVIDIA.GetAssociatedNvidiaDisplayHandle("\\.\DISPLAY2")    ; ==> -570425342
Edit2: Das gewünschte Feature unterschiedliche DV für unterschiedliche Monitore funktioniert und werd ich im Script Forum bei Gelegenheit posten

Edit: jetzt funktioniert nur noch das Auslesen des Namens mit GetAssociatedNvidiaDisplayHandle nicht

Re: Projekt NVIDIA

Post by just me » 23 Dec 2014, 04:17

if !(NvStatus := DllCall(NvAPI._GetAssociatedNvidiaDisplayHandle, "AStr", szDisplayName, "Int*", pNvDispHandle, "CDECL"))?


Du könntest auch mal versuchen, ob die "UnAttached" Funktionen etwas liefern.

Re: Projekt NVIDIA

Post by jNizM » 23 Dec 2014, 04:15

Nein benutze kein Ansi...
habe das cp0 nur von dir übernommen
return StrGet(&szDesc, "CP0")


Edit:
MsgBox % NvAPI._GetAssociatedNvidiaDisplayHandle := DllCall(NvAPI.DllFile "\nvapi_QueryInterface", "UInt", 0x35C29134, "CDECL UPtr")
==> 8791621922496

MsgBox % NvAPI._GetAssociatedNvidiaDisplayName := DllCall(NvAPI.DllFile "\nvapi_QueryInterface", "UInt", 0x22A78B05, "CDECL UPtr")
==> 8791621922832

Re: Projekt NVIDIA

Post by just me » 23 Dec 2014, 04:12

Lass Dir doch einfach mal per MsgBox anzeigen, ob die Handles aus dem direkten Aufruf und dem Aufruf innerhalb der Funktion übereinstimmen. Wenn ja, haben sie die Funktion vielleicht stillgelegt?

Zum letzten Posting: Benutzt Du AHK ANSI bzw. übergibst Du einen ANSI String?

Re: Projekt NVIDIA

Post by jNizM » 23 Dec 2014, 04:08

hmn...

GetAssociatedNvidiaDisplayHandle mit "\\.\DISPLAY1" gibt mir auch -6 zurück

Code: Select all

GetAssociatedNvidiaDisplayHandle(szDisplayName := "\\.\DISPLAY1")
{
    StrPut(&szDisplayName, "CP0")
    if !(NvStatus := DllCall(NvAPI._GetAssociatedNvidiaDisplayHandle, "Ptr", &szDisplayName, "Int*", pNvDispHandle, "CDECL"))
        return pNvDispHandle
    return "*" NvStatus
}

Re: Projekt NVIDIA

Post by just me » 23 Dec 2014, 03:55

Code: Select all

GetAssociatedNvidiaDisplayName()
{
    NvDispHandle := NvAPI.EnumNvidiaDisplayHandle(1)
Fehlt da nicht ein _? Edit: Quatsch!

So wie ich die API Referenz verstehe, könnte man als Namen auch die Ausgabe von SysGet, MonName, MonitorName verwenden.

Re: Projekt NVIDIA

Post by jNizM » 23 Dec 2014, 02:25

Ich bin grad dabei NvAPI_GetAssociatedNvidiaDisplayName & NvAPI_GetAssociatedNvidiaDisplayHandle in ahk umzuschreiben, aber

Laut dem Pascal-Code mach ich das doch eigtl richtig o.O

Code: Select all

procedure TestDisplayAPI;
var
    i     : Integer;
    hnd   : NvDisplayHandle;
    name  : NvAPI_ShortString;
begin
    writeln('Display APIs: ');
    i:=0;
    hnd:=0;
    while NvAPI_EnumNVidiaDisplayHandle(i, hnd) = NVAPI_OK do begin
        if NvAPI_GetAssociatedNVidiaDisplayName(hnd, name) = NVAPI_OK then
            writeln('Display: ', name);
        inc(i);
    end;
    writeln;
end;
Ich hab zwei Monitore und egal ob ich 0 oder 1 bei EnumNvidiaDisplayHandle übergeben kommt *-6
(NVAPI_NVIDIA_DEVICE_NOT_FOUND = -6, //!< No NVIDIA display driver, or NVIDIA GPU driving a display, was found.)

Code: Select all

GetAssociatedNvidiaDisplayName()
{
    NvDispHandle := NvAPI.EnumNvidiaDisplayHandle(1)
    VarSetCapacity(szDisplayName, NvAPI.NVAPI_SHORT_STRING_MAX, 0)
    if !(NvStatus := DllCall(NvAPI._GetAssociatedNvidiaDisplayName, "Ptr", NvDispHandle, "Ptr", &szDisplayName, "CDECL"))
        return StrGet(&szDisplayName, "CP0")
    return "*" NvStatus
}

Direkt bei EnumNvidiaDisplayHandle bekomme ich bei 0 und 1 ein Handle zurück (-xxxxxxxxx)

Code: Select all

EnumNvidiaDisplayHandle(thisEnum := 0)
{
    if !(NvStatus := DllCall(NvAPI._EnumNvidiaDisplayHandle, "UInt", thisEnum, "Int*", pNvDispHandle, "CDECL"))
        return pNvDispHandle
    return "*" NvStatus
}

Re: Projekt NVIDIA

Post by jNizM » 08 Dec 2014, 10:09

Skripte und Funktionen (EN) ==> AutoHotkey & NVIDIA (NvAPI)

Re: Projekt NVIDIA

Post by jNizM » 27 Nov 2014, 09:57

Da GPU-Z auch nicht anzeigt, muss ich später mal schauen, da ich jetzt erstmal weg muss.
Trotzdem Danke für die Mühe

Top