Old 11th September 2004, 06:30   #1
JeronimoColon
Junior Member
 
Join Date: Sep 2004
Location: New York City
Posts: 39
Unhappy Weird System.dll problem...

If I call an API by itself it works, but if I call the same API followed by a second API the first API fails.

What's even stranger is if I call the first API and then DetailPrint a random variable the first API fails.

------------------------------------------------
Ex. 1: Uncomment Second API to make fail.
------------------------------------------------
!define APPNAME "Detect New Devices"
!define APPNAMEANDVERSION "Detect New Devices 1.0"

Name "${APPNAMEANDVERSION}"
InstallDir "$PROGRAMFILES\Detect New Devices"
OutFile "DetectNewDevices.exe"

!include "MUI.nsh"

!define MUI_ABORTWARNING

!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_INSTFILES

!insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_RESERVEFILE_LANGDLL

Section "Detect New Devices" Section1
SetOverwrite on
SetOutPath $INSTDIR
Call GetDevNode
SectionEnd

!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${Section1} ""
!insertmacro MUI_FUNCTION_DESCRIPTION_END

Function GetDevNode
SetPluginUnload alwaysoff
StrCpy $1 ""
System::Call 'setupapi::CM_Locate_DevNodeA(*i .r0, *t r1r1, i r2r2) i .r3'
;System::Call 'setupapi::CM_Reenumerate_DevNode(*i r0r0, i r4r4) i .r5'
DetailPrint "Var0: $0"
DetailPrint "Var1: $1"
DetailPrint "Var2: $2"
DetailPrint "Ret Val: $3"

SetPluginUnload manual
System::Free 0
FunctionEnd
------------------------------------------------
Ex. 2: Uncomment DetailPrint "Weird: $5" to make fail
------------------------------------------------
!define APPNAME "Detect New Devices"
!define APPNAMEANDVERSION "Detect New Devices 1.0"

Name "${APPNAMEANDVERSION}"
InstallDir "$PROGRAMFILES\Detect New Devices"
OutFile "DetectNewDevices.exe"

!include "MUI.nsh"

!define MUI_ABORTWARNING

!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_INSTFILES

!insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_RESERVEFILE_LANGDLL

Section "Detect New Devices" Section1
SetOverwrite on
SetOutPath $INSTDIR
Call GetDevNode
SectionEnd

!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${Section1} ""
!insertmacro MUI_FUNCTION_DESCRIPTION_END

Function GetDevNode
SetPluginUnload alwaysoff
StrCpy $1 ""
System::Call 'setupapi::CM_Locate_DevNodeA(*i .r0, *t r1r1, i r2r2) i .r3'
DetailPrint "Var0: $0"
DetailPrint "Var1: $1"
DetailPrint "Var2: $2"
DetailPrint "Ret Val: $3"

;DetailPrint "Weird: $5"
SetPluginUnload manual
System::Free 0
FunctionEnd
------------------------------------------------

An help on this would be greatly appreciated.

Thanks.

jc3
JeronimoColon is offline   Reply With Quote
Old 11th September 2004, 09:54   #2
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
CM_Locate_DevNode takes a string as the second parameter, not a pointer to a string. CM_Reenumerate_DevNode takes an integer (handle, DEVINST) as the first parameter, not a pointer to an integer.

You should check the return values, it's the first call that fails, not the second.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 11th September 2004, 23:30   #3
JeronimoColon
Junior Member
 
Join Date: Sep 2004
Location: New York City
Posts: 39
Thank you for your reply.

EDITED
I'm still having problems with this, but it looks like it something machine specific where It's working when it shouldn't but isn't when it should.

I had the change to try this on another PC today and it works properly, but works in the reverse on my laptop.

Go figure.

Thanks again.

jc3
JeronimoColon is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump