GetFunction fails...but just in this code

Just starting out? Need help? Post your questions and find answers here.
BarryG
Addict
Addict
Posts: 4221
Joined: Thu Apr 18, 2019 8:17 am

Re: GetFunction fails...but just in this code

Post by BarryG »

I wonder if this one of those situations where you need to manually specify the full path to the DLL? I've been bitten by that before.

Code: Select all

Libef=OpenLibrary(#PB_Any,"comctl32.dll") ; Current version without the path.
Libef=OpenLibrary(#PB_Any,"c:\windows\system32\comctl32.dll") ; Maybe this works?
User avatar
jacdelad
Addict
Addict
Posts: 2032
Joined: Wed Feb 03, 2021 12:46 pm
Location: Riesa

Re: GetFunction fails...but just in this code

Post by jacdelad »

I thought of that too, but that doesn't help.
Using LoadLibrary_() I finally get version information after loading, but again it's 5.82.

I will go throught the working original code step by step and try to reproduce it.
Thanks for everyone who helped me!
Good morning, that's a nice tnetennba!

PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
User avatar
jacdelad
Addict
Addict
Posts: 2032
Joined: Wed Feb 03, 2021 12:46 pm
Location: Riesa

Re: GetFunction fails...but just in this code

Post by jacdelad »

I'm stuck at this again. I tried to run the code and it loads some old 5.82 version (which does not support task dialogs and the library doesn't have such a function).
This may be a stupid question, but is this maybe in relation with the reintroduced XP support?

Edit: Ok, so I got some more information. When I use it in my bigger project, it loads a 6.0 version. So I assume, something in the code (a Usexxx() or something else) triggers my program to load the new version. But I'm totally lost, what it is...
Also, when I create an EXE from my code of the first post, it doesn't have a manifest. Is this somehow related to?
Good morning, that's a nice tnetennba!

PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
User avatar
idle
Always Here
Always Here
Posts: 6040
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: GetFunction fails...but just in this code

Post by idle »

how about this ?
pb 6.03 win 11 x64

Code: Select all

CompilerIf #PB_Compiler_IsMainFile
  EnableExplicit
CompilerEndIf

ImportC "comctl32.lib" 
   TaskDialogIndirect(tdlgx, *ClickedButtonx, *SelRadiox, *fVerifyx)
EndImport 

#TD_WARNING_ICON = -1
#TD_ERROR_ICON = -2
#TD_INFORMATION_ICON = -3
#TD_SHIELD_ICON = -4

#TDF_USE_COMMAND_LINKS           = $10   ;Commandlinks statt normale Buttons verwenden
#TDF_ENABLE_HYPERLINKS           = $1    ;Links automatisch anzeigen
#TDF_USE_HICON_MAIN              = $2    ;Eigenes Icon verwenden
#TDF_USE_HICON_FOOTER            = $4    ;Icon in den Footer verschieben (?)
#TDF_EXPAND_FOOTER_AREA          = $40   ;Erweiterter Text wird im Footer angezeigt
#TDF_EXPANDED_BY_DEFAULT         = $80
#TDF_VERIFICATION_FLAG_CHECKED   = $100
#TDF_SHOW_PROGRESS_BAR           = $200
#TDF_SHOW_MARQUEE_PROGRESS_BAR   = $400
#TDF_CALLBACK_TIMER              = $800  ;Callback-Funktion etwa alle 200ms aufrufen
#TDF_POSITION_RELATIVE_TO_WINDOW = $1000 ;Position relativ zu ParenthWnd
#TDF_NO_DEFAULT_RADIO_BUTTON     = $4000
#TDF_CAN_BE_MINIMIZED            = $8000

#TD_ICON_NONE                   = 0
#TD_ICON_SHIELD_COLORED_GREY    = 65527
#TD_ICON_SHIELD_OK_COLORED      = 65528
#TD_ICON_SHIELD_ERROR_COLORED   = 65529
#TD_ICON_SHIELD_WARNING_COLORED = 65530
#TD_ICON_SHIELD_COLORED         = 65531
#TD_ICON_SHIELD                 = 65532
#TD_ICON_SHIELD_QUESTION        = 65533
#TD_ICON_ERROR                  = 65534
#TD_ICON_QUESTION               = 65535

Structure TASKDIALOGCONFIG
  cbSize.l
  hwndParent.i
  hInstance.i
  dwFlags.l
  dwCommonButtons.l
  *pszWindowTitle
  StructureUnion
    hMainIcon.i
    *pszMainIcon
  EndStructureUnion
  *pszMainInstruction
  *pszContent
  cButtons.l
  *pButtons.TASKDIALOG_BUTTON
  nDefaultButton.l
  cRadioButtons.l
  *pRadioButtons.TASKDIALOG_BUTTON
  nDefaultRadioButton.l
  *pszVerificationText
  *pszExpandedInformation
  *pszExpandedControlText
  *pszCollapsedControlText
  StructureUnion
    hFooterIcon.i
    *pszFooterIcon
  EndStructureUnion
  *pszFooter
  *pfCallback
  *lpCallbackData
  cxWidth.l
EndStructure
Structure TASKDIALOG_BUTTON
  nButtonID.l
  *pszButtonText
EndStructure

Global fVerifyx, SelRadiox

Procedure Task_DialogIndirect(tdlgx)
  Protected ClickedButtonx,*Task_Dialog_Func
  ;If Libef
  ;  *Task_Dialog_Func = GetFunction(Libef, "TaskDialogIndirect")
  ;  Debug *Task_Dialog_Func
  ;  If *Task_Dialog_Func
      TaskDialogIndirect(tdlgx, @ClickedButtonx, @SelRadiox, @fVerifyx)
   ; EndIf
  ;EndIf
  ;CloseLibrary(Libef)
  If ClickedButtonx<1000
    ProcedureReturn 0
  Else
    ProcedureReturn ClickedButtonx-1000
  EndIf
EndProcedure

Global Dim TD_Buttons.TASKDIALOG_BUTTON(8)
Define tdcount
For tdcount=0 To ArraySize(TD_Buttons())
  TD_Buttons(tdcount)\nButtonID=tdcount+1001
Next
Global Dim TD_RADIOButtons.TASKDIALOG_BUTTON(8)
For tdcount=0 To ArraySize(TD_RADIOButtons())
  TD_RADIOButtons(tdcount)\nButtonID=tdcount+1001
Next

Procedure TaskDialog(title.s,flags,icon,headline.s,text.s,bCount,defbutton,rcount,defradio,checkbox.s,expando.s,expand.s,collapse.s,footericon,footer.s,Parent=0)
  Protected tdlg.TASKDIALOGCONFIG
  tdlg\cbSize = SizeOf(tdlg)
  tdlg\hwndParent = Parent;#Null
  tdlg\hInstance = #Null
  tdlg\dwFlags = flags
  tdlg\dwCommonButtons = #Null
  tdlg\pszWindowTitle = @title
  tdlg\hMainIcon = icon
  tdlg\pszMainInstruction = @headline
  tdlg\pszContent = @text
  tdlg\cButtons = bCount
  tdlg\pButtons = @TD_Buttons(0)\nButtonID
  tdlg\cRadioButtons = rcount
  tdlg\pRadioButtons = @TD_RADIOButtons(0)\nButtonID
  tdlg\nDefaultButton = defbutton
  tdlg\nDefaultRadioButton = defradio
  tdlg\pszVerificationText = @checkbox
  tdlg\pszExpandedInformation = @Expando
  tdlg\pszExpandedControlText = @expand
  tdlg\pszCollapsedControlText = @collapse
  tdlg\hFooterIcon = footericon
  tdlg\pszFooter = @footer
  tdlg\pfCallback = #Null
  ProcedureReturn Task_DialogIndirect(tdlg)
EndProcedure

If #PB_Compiler_IsMainFile
  Define eintext.s,enttext.s,backtext.s,ClickedButton
  eintext.s="iTAC einfügen"+#LF$+"Fügt alle erforderlichen Daten für die iTAC-Anbindung ein. Erstellt außerdem eine Pre-Datei, die aber manuell angepasst werden muss."
  TD_Buttons(0)\pszButtonText = @eintext
  enttext.s="iTAC entfernen"+#LF$+"Entfernt alle iTAC-relevanten Daten und stellt den Normalzustand mit DMC wieder her."
  TD_Buttons(1)\pszButtonText = @enttext
  backtext.s="Zurück"+#LF$+"Keine Änderungen vornehmen"
  TD_Buttons(2)\pszButtonText = @backtext
  TD_RADIOButtons(0)\pszButtonText = @"Radio 1"
  TD_RADIOButtons(1)\pszButtonText = @"Radio 2"
  TD_RADIOButtons(2)\pszButtonText = @"Radio 3"
  ClickedButton = TaskDialog("iTAC-Optionen",#TDF_USE_COMMAND_LINKS|#TDF_EXPAND_FOOTER_AREA,#TD_ICON_SHIELD_OK_COLORED,"Wählen Sie eine iTAC-Option aus:","Der iTAC kann eingefügt oder entfernt werden.",3,3,0,0,"","","","",0,"")
  ;fVerifyx      -> Checkbox gecheckt
  ;SelRadiox     -> Gewählter Radiobutton (1. Index ist 1)
  ;ClickedButton -> Gewählter Button (1. Index ist 1)
EndIf

User avatar
jacdelad
Addict
Addict
Posts: 2032
Joined: Wed Feb 03, 2021 12:46 pm
Location: Riesa

Re: GetFunction fails...but just in this code

Post by jacdelad »

"Unresolved external symbol '_TaskDialogIndirect' etc.
Windows 10 x64

The file insists on using an old version of comctl32.dll.
Good morning, that's a nice tnetennba!

PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
User avatar
idle
Always Here
Always Here
Posts: 6040
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: GetFunction fails...but just in this code

Post by idle »

In 6.04 Fred added the fix to load system libs from the proper directories.
Did you try absolute paths?

edit: I tried the absolute "C:\Windows\System32\comctl32.dll path and the function doesn't exist in that version.
so it must be loading an older version probably there are likely numerous on the system

The compiler command line
/FORCE:MULTIPLE /ENTRY:PureBasicStart /OUT:"D:\idle\test.exe" /SUBSYSTEM:Windows,5.0 /NODEFAULTLIB /LIBPATH:"C:\Program Files\PureBasic\Compilers" /LIBPATH:"C:\Program Files\PureBasic\PureLibraries\Windows\Libraries" PureBasic.obj SystemBase.lib StringUtility.lib UnicodeFunctions.lib MSVCRT.lib KERNEL32.lib USER32.lib GDI32.lib COMDLG32.lib ADVAPI32.lib COMCTL32.lib OLEAUT32.lib Library.lib "C:\Program Files\PureBasic\compilers/objectmanager.lib" SimpleList.lib Array.lib Memory.lib "C:\Program Files\PureBasic\compilers/stringmanager.lib" kernel32.lib PureBasic.res

and the loaded version is in
comctl32.dll C:\WINDOWS\WinSxS\amd64_microsoft.windows.common-controls_6595b64144ccf1df_6.0.22621.2215_none_270d72677387dfc3\comctl32.dll Microsoft Corporation 6.10 (WinBuild.160101.0800)

grab a copy of ProcessMonitor
https://download.sysinternals.com/files ... onitor.zip

create an test.exe use find click click properties and see what module version is being loaded
User avatar
jacdelad
Addict
Addict
Posts: 2032
Joined: Wed Feb 03, 2021 12:46 pm
Location: Riesa

Re: GetFunction fails...but just in this code

Post by jacdelad »

I tried absolute paths too, with the same result. Also, searching through the many versions in the cryptic subfolders shouldn't be the solution.
I still think it's a problem because the minimal exe doesn't have a manifest...but I'm not sure.
However, I'm going to sleep and will be able to test more in 16 hours.
Good morning, that's a nice tnetennba!

PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
User avatar
idle
Always Here
Always Here
Posts: 6040
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: GetFunction fails...but just in this code

Post by idle »

have a look at my previous post tomorrow you might be able to track down what's happening
User avatar
ChrisR
Addict
Addict
Posts: 1484
Joined: Sun Jan 08, 2017 10:27 pm
Location: France

Re: GetFunction fails...but just in this code

Post by ChrisR »

The use of comctl32 5.82 or 6.0 in WinSxS seems to depend on the "Enable Modern Theme support" compiler option, the manifest.

Image
User avatar
jacdelad
Addict
Addict
Posts: 2032
Joined: Wed Feb 03, 2021 12:46 pm
Location: Riesa

Re: GetFunction fails...but just in this code

Post by jacdelad »

Ah finally, you're right! I also found out something else: It only works, if it's part of a project. Looks to me like the "modern theme"-option is not used when no project is loaded (I set it in the compiler standard options to "on" and it doesn't work). Maybe someone can confirm this?
Good morning, that's a nice tnetennba!

PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
Post Reply