Can't we use SHELL32 dll like USER32?

Windows specific questions.
Tourist Trap
Posts: 2756
Joined: Jun 02, 2015 16:24

Can't we use SHELL32 dll like USER32?

Postby Tourist Trap » Jan 18, 2019 15:25

Hello,

I tried to run this for example:

Code: Select all

#Include "windows.bi"

Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As HWND, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

ShellExecute(HWND_DESKTOP,"open","command.com","","",SW_SHOW)

MessageBox(HWND_DESKTOP,"Test","Hello",MB_OK)

It's taken from the FB forum so it musk have been working in the past. Here on WIN10 64 I get a "cannot find -lshell32.dll".

I tried to get a "libshell32.a" from somewhere else, and tried #INCLIB also, it did nothing good.

Someone has an idea on this?

Thanks
Iczer
Posts: 47
Joined: Jul 04, 2017 18:09

Re: Can't we use SHELL32 dll like USER32?

Postby Iczer » Jan 18, 2019 15:56

Its already in standard includes, see:

Code: Select all

#Include "win\shellapi.bi"
Tourist Trap
Posts: 2756
Joined: Jun 02, 2015 16:24

Re: Can't we use SHELL32 dll like USER32?

Postby Tourist Trap » Jan 18, 2019 15:57

Iczer wrote:Its already in standard includes, see:

Code: Select all

#Include "win\shellapi.bi"

I missed that, thanks friend :)

edit:
unfortunately this doesn't work...
Can you try this from your side?

Code: Select all

#include "windows.bi"
#include "win\shellapi.bi"

#undef ShellExecute

Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As HWND, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long


A said before, #inclib "shell32" fails for me.
jj2007
Posts: 1135
Joined: Oct 23, 2016 15:28
Location: Roma, Italia
Contact:

Re: Can't we use SHELL32 dll like USER32?

Postby jj2007 » Jan 18, 2019 16:35

Your code (the one at the top) builds and runs fine with -gen gcc -Wc -Ofast -s console and gcc version 8.1.0, but it chokes indeed with Gas32 and Gcc64.
Tourist Trap
Posts: 2756
Joined: Jun 02, 2015 16:24

Re: Can't we use SHELL32 dll like USER32?

Postby Tourist Trap » Jan 18, 2019 16:49

jj2007 wrote:Your code (the one at the top) builds and runs fine with -gen gcc -Wc -Ofast -s console and gcc version 8.1.0, but it chokes indeed with Gas32 and Gcc64.

Thanks. I guess I don't even have a good version of GCC:

Code: Select all

C:\Program Files (x86)\FreeBasic\FB64_106\fbc_win64_mingw\fbc.exe -m "C:\Program Files (x86)\WinFBE-master\TMPF2BA.bas" "" -v -gen gcc -Wc -Ofast -s console

FreeBASIC Compiler - Version 1.06.0 (11-22-2018), built for win64 (64bit)
Copyright (C) 2004-2016 The FreeBASIC development team.
standalone
target:       win64, x86-64, 64bit
C:\PROGRA~2\FREEBA~1\FB64_106\FBC_WI~1\bin\win64\ld.exe: cannot find -lshell32
C:\PROGRA~2\FREEBA~1\FB64_106\FBC_WI~1\bin\win64\ld.exe: cannot find -lshell32.dll

Anyway, then it is maybe a bug, since it worked in the past.
coderJeff
Site Admin
Posts: 2847
Joined: Nov 04, 2005 14:23
Location: Ontario, Canada
Contact:

Re: Can't we use SHELL32 dll like USER32?

Postby coderJeff » Jan 18, 2019 22:26

Tourist Trap wrote:Thanks. I guess I don't even have a good version of GCC:

Not sure of everything that you might have installed and where. In the fbc folder should be sub-folders:

./lib/win32/libshell32.dll.a -- import lib for 32-bit
./lib/win64/libshell32.dll.a -- import lib for 64-bit

And fbc should just find them.

--

For the BYVAL AS STRING behaviour, from about version 0.16.0 (2006)
todo.txt wrote:[ ] "byval as string" arguments should make a temp copy (including descriptor) of the param passed:
- must pass (?) the address of the temp descriptor, not the string data, what will break *all* functions assuming the latter - they would have to be declared as zstring ptr, what will need more changes in users' code, because the non-implicit pointer deref


And in 2014:
changelog.txt wrote:Version 1.00.0 (former 0.91.0):

[added]
- BYVAL AS STRING is now working properly: it now has BYVAL semantics and no longer behaves like BYREF AS ZSTRING. Modifications made by the callee are not visible to the caller, as for other BYVAL parameters. (BYVAL AS STRING is implemented by copying the string argument into a temporary STRING, whose descriptor is then passed BYREF to the procedure)

That TODO/BUG was hanging around for a while.
Tourist Trap
Posts: 2756
Joined: Jun 02, 2015 16:24

Re: Can't we use SHELL32 dll like USER32?

Postby Tourist Trap » Jan 19, 2019 9:42

coderJeff wrote:
Tourist Trap wrote:Thanks. I guess I don't even have a good version of GCC:

Not sure of everything that you might have installed and where. In the fbc folder should be sub-folders:

./lib/win32/libshell32.dll.a -- import lib for 32-bit
./lib/win64/libshell32.dll.a -- import lib for 64-bit

And fbc should just find them.

Hi coderJeff,

thanks for answering. I took my 1.06 fb64 version from the stw's repository. It's true that it was missing already at start many things that I added later (in the includes and so on). Here I first grabbed a libshell32.dll.a from some other software (SageMATH) on my computer. It didn't work.
I also read dodicat saying he had to put SHELL32.DLL in the program directory (is some topic around), and the test code was from a old post from the forum. That's why I thought it should be some problem behind this. It seems not maybe. Can we get the 1.06 as a release those days? I must admit that I had not enought time to look around for the most fresh version of fbc those days.


coderJeff wrote:For the BYVAL AS STRING behaviour, from about version 0.16.0 (2006)
todo.txt wrote:[ ] "byval as string" arguments should make a temp copy (including descriptor) of the param passed:
- must pass (?) the address of the temp descriptor, not the string data, what will break *all* functions assuming the latter - they would have to be declared as zstring ptr, what will need more changes in users' code, because the non-implicit pointer deref

That TODO/BUG was hanging around for a while.

However in a old post from here this code was succesfully used. I can't find it back unfortunately.
jj2007
Posts: 1135
Joined: Oct 23, 2016 15:28
Location: Roma, Italia
Contact:

Re: Can't we use SHELL32 dll like USER32?

Postby jj2007 » Jan 19, 2019 10:30

coderJeff wrote:Not sure of everything that you might have installed and where. In the fbc folder should be sub-folders:

./lib/win32/libshell32.dll.a -- import lib for 32-bit
./lib/win64/libshell32.dll.a -- import lib for 64-bit

And fbc should just find them.

At the risk of sparking a little war: The weakest points of FreeBasic are IMHO that
- there is no installer
- the documentation is all over the place, in this forum and elsewhere
- there are many add-ons and libraries without clear installation instructions, somewhere in this forum
- there are at least three compilers behind the compiler (Gas32, Gcc32, Gcc66; MinGW?)
- fbc "should just find them"? Setting paths maybe? Global environment variables are IMHO the worst legacy of DOS days
- several competing IDEs, probably setting their own paths (personally, I use an editor and three batch files for the 3 compilers; it works but no idea why...)

My FB folder has lots of subfolders, I am struggling to understand how I accumulated 4x gcc.exe, plus several versions in C:\TDM***, e.g. C:\TDM-GCC-64\bin\gcc.exe

It's an ugly mess, honestly. And it would be very helpful, if one really competent person would be given a sticky post at a central place of this forum explaining what is a sane FreeBasic installation.

[/rant]
Tourist Trap
Posts: 2756
Joined: Jun 02, 2015 16:24

Re: Can't we use SHELL32 dll like USER32?

Postby Tourist Trap » Jan 19, 2019 13:21

jj2007 wrote:what is a sane FreeBasic installation.

To be honest I think it's also partly my fault. I didn't want to keep using the 1.05 due to the fact that everyone in the forum seems to be using the 1.06. But it's not a release, so I grabbed it a little too quickly. Furthermore, I use WinFBE now, that can compile to 64 or 32. And I may make addition to my FB64 directory and compile the FB32's one. This adds to the confusion. Fortunately I don't need SHELL32 for now, so I will wait until I download a more complete version, or the release :)
coderJeff
Site Admin
Posts: 2847
Joined: Nov 04, 2005 14:23
Location: Ontario, Canada
Contact:

Re: Can't we use SHELL32 dll like USER32?

Postby coderJeff » Jan 19, 2019 14:01

fbc looks for files relative to where it is installed and depends on if it is the normal or standalone version. I think the most concise description of where files are supposed to be located can be found here:
Normal vs. Standalone FreeBASIC

For example, in standalone packages, win32 & win64 can be installed to same folder, however the top-level fbc.exe will conflict. So easiest to rename one or both (e.g. fbc-win32.exe, fbc-win64.exe).

An IDE will have it's own options for configuration of where it expects to find files.

Tourist Trap wrote:However in a old post from here this code was succesfully used. I can't find it back unfortunately.

That is old! viewtopic.php?p=12565#p12565

jj2007 wrote:My FB folder has lots of subfolders, I am struggling to understand how I accumulated 4x gcc.exe, plus several versions in C:\TDM***, e.g. C:\TDM-GCC-64\bin\gcc.exe

It's an ugly mess, honestly. And it would be very helpful, if one really competent person would be given a sticky post at a central place of this forum explaining what is a sane FreeBasic installation.


Heh, "sane" that rules me out!

I have every version of fbc installed from 0.14.0 to 1.05.0, the development tree, plus several versions of tool chaings (mingw***). I used to also have TDM* and win-builds tool chains installed but they haven't been updated in years, so I am only using mingw.org and mingw-w64 tool chains now. I don't use any IDE in a way most users would, since I regularly switch between configurations.
St_W
Posts: 1465
Joined: Feb 11, 2009 14:24
Location: Austria
Contact:

Re: Can't we use SHELL32 dll like USER32?

Postby St_W » Jan 19, 2019 20:35

jj2007 wrote:- there is no installer

There is an installer for win32 (see https://sourceforge.net/projects/fbc/fi ... 20Windows/). Some years I ago I modified the install script to create a combined win32/win64 installer, but I'm not sure whether that's needed. Personally I always download the zip archives. But I agree that FB is not beginner friendly, at least not in today's world (anymore?).

Return to “Windows”

Who is online

Users browsing this forum: No registered users and 1 guest