Board index » cppbuilder » Progress with SHGetSetSettings function

Progress with SHGetSetSettings function


2004-08-16 03:45:42 AM
cppbuilder57
Well, progress marches onward here. I now have a small program doing a GET and dumping it to stdout just fine, yea!!!
So, using roughly the same syntax I just wrote up a SET test, bang it crashes! First I noticed MS has defined three additional constants for the dwMask in the header file than the structure has
elements to hold current settings, so I backed out those three, still crashes. The MSDN docs do not spefify it this function needs to be run within a special context, such as after running some other
function to get Explorer ready to have settings tinkered with.
Next up I guess I will try to set just one settings and not the entire set of them.
Any other suggestions of things for me to try as I track this down?
I created a header pulling the correct stuff out of the MS header file to get the one function working.
#include <windows.h>
#include "SetShellSettings.h"
typedef void (__stdcall *MYPROC)( LPSHELLSTATE, DWORD, BOOL);
int main()
{
HINSTANCE hSHELLLib;
BOOL fFreeResult;
MYPROC ProcAdd;
DWORD dwMask;
SHELLSTATEW lpss;
dwMask = SSF_SHOWALLOBJECTS |
SSF_SHOWEXTENSIONS |
SSF_SHOWCOMPCOLOR |
SSF_SHOWSYSFILES |
SSF_DOUBLECLICKINWEBVIEW |
SSF_SHOWATTRIBCOL |
SSF_DESKTOPHTML |
SSF_WIN95CLASSIC |
SSF_DONTPRETTYPATH |
SSF_SHOWINFOTIP |
SSF_MAPNETDRVBUTTON |
SSF_NOCONFIRMRECYCLE |
SSF_HIDEICONS |
SSF_FILTER |
SSF_WEBVIEW |
SSF_SHOWSUPERHIDDEN |
SSF_SEPPROCESS |
SSF_NONETCRAWLING |
SSF_STARTPANELON |
SSF_SHOWSTARTPAGE;
hSHELLLib = LoadLibrary( "SHELL32.DLL");
if( hSHELLLib != NULL ){
ProcAdd = ( MYPROC)GetProcAddress( hSHELLLib, TEXT( "SHGetSetSettings"));
if( ProcAdd != NULL )
lpss.fShowAllObjects = 0;
lpss.fShowExtensions = 0;
lpss.fNoConfirmRecycle = 0;
lpss.fShowSysFiles = 0;
lpss.fShowCompColor = -1;
lpss.fDoubleClickInWebView = 0;
lpss.fDesktopHTML = 0;
lpss.fWin95Classic = -1;
lpss.fDontPrettyPath = -1;
lpss.fShowAttribCol = -1;
lpss.fMapNetDrvBtn = -1;
lpss.fShowInfoTip = -1;
lpss.fHideIcons = -1;
lpss.fWebView = -1;
lpss.fFilter = -1;
lpss.fShowSuperHidden = -1;
lpss.fNoNetCrawling = 0;
lpss.fSepProcess = 0;
lpss.fStartPanelOn = 0;
lpss.fShowStartPage = 0;
ProcAdd( &lpss, dwMask, TRUE);
fFreeResult = FreeLibrary( hSHELLLib);
}
return 0;
}
--
Michael Lueck
Lueck Data Systems
Remove the upper case letters NOSPAM to contact me directly.
 
 

Re:Progress with SHGetSetSettings function

Michael Lueck wrote:
Quote
Any other suggestions of things for me to try as I track this down?
I created a header pulling the correct stuff out of the MS header file to get the one function working.
Did you make sure those BOOLs are BitFlags?
Are you using the structure shown at
msdn.microsoft.com/library/default.asp
Quote
#include <windows.h>
#include "SetShellSettings.h"

typedef void (__stdcall *MYPROC)( LPSHELLSTATE, DWORD, BOOL);

SHELLSTATEW lpss;
Why the W? There aren't any chars in there?
Quote
ProcAdd = ( MYPROC)GetProcAddress( hSHELLLib, TEXT( "SHGetSetSettings"));
You can call ProcAdd SHGetSetSettings instead to make the code easier
to read
Quote
if( ProcAdd != NULL )
Do you have braces here? This posted code doesn't properly skip using
a non-existant function.
Quote
lpss.fShowAllObjects = 0;
lpss.fShowSuperHidden = -1;

ProcAdd( &lpss, dwMask, TRUE);
Did you run this (SHGetSetSettings) with FALSE to Read the values?
Does that part work?
Have you verified that shell32.dll is Vers 5 or higher?
Maybe Read/Set/Write would help?
Quote
fFreeResult = FreeLibrary( hSHELLLib);
}
return 0;
}
 

Re:Progress with SHGetSetSettings function

While this is the command line tools group and a good place to get
answers on using the command line tools, your question is about the
native Windows API. You might enjoy better results by asking that
question in the group whose subject is that API
borland.public.cppbuilder.nativeapi
. Ed
Quote
Michael Lueck wrote in message
news:411fbd33$ XXXX@XXXXX.COM ...
 

{smallsort}

Re:Progress with SHGetSetSettings function

Ed Mulroy [TeamB] wrote:
Quote
borland.public.cppbuilder.nativeapi
All right, I can try. I figured as much as this groups sends the CPPBuilder folks back from where they came from, they would send free command line tools back to this group.
--
Michael Lueck
Lueck Data Systems
Remove the upper case letters NOSPAM to contact me directly.
 

Re:Progress with SHGetSetSettings function

Bob Gonder wrote:
Quote
Did you make sure those BOOLs are BitFlags?
Hua? I copied the correct portion (structures and constants) from the MS PSDK header file....???
Quote
Are you using the structure shown at
msdn.microsoft.com/library/default.asp
See above...
Quote
>SHELLSTATEW lpss;

Why the W? There aren't any chars in there?
??? No naming standards for this C hack. MS had unicode and non-unicode support in their header, so I kept the non-unicode portion as I doubt the borland compiler sets the compile option the if logic
in the header was using
Quote
You can call ProcAdd SHGetSetSettings instead to make the code easier
to read
Once the code does more than GPF I'll clean away
Quote
Do you have braces here? This posted code doesn't properly skip using
a non-existant function.
Good catch. I am a C/C++ hack at best.
Quote
Did you run this (SHGetSetSettings) with FALSE to Read the values?
Does that part work?
Yes, that is my GET program which dumps "something" perfectly to the screen. I now say something as I ran my GET program on a box without and shell setting tweaks and found it dumps the same data as
my tweaked PC... ggggrrrr!!!! I hate SDK's with 1) no samples and 2) just enough help to be 10% useless! ;-)
Quote
Have you verified that shell32.dll is Vers 5 or higher?
Maybe Read/Set/Write would help?
I would assume so since I am on Win2K SP4 and IE6SP1 ala all hot fixes, but just for you...
The CRC32 of the specified file is: D2FDCDAC
The FileVersion of the specified file is: 5.00.3900.6922
--
Michael Lueck
Lueck Data Systems
Remove the upper case letters NOSPAM to contact me directly.
 

Re:Progress with SHGetSetSettings function

Michael Lueck wrote:
Quote
Bob Gonder wrote:

>Did you make sure those BOOLs are BitFlags?

Hua? I copied the correct portion (structures and constants) from the MS PSDK header file....???

>Are you using the structure shown at
>msdn.microsoft.com/library/default.asp

See above...
Afraid that doesn't tell me anything. My copy of the MS PSDK ShlObj.h
(direct from MS) doesn't include SHGetSetSettings.
I was asking if what you copied matched the "current" version, as
posted at that URL.
Quote
>>SHELLSTATEW lpss;
>
>Why the W? There aren't any chars in there?

??? No naming standards for this C hack. MS had unicode and non-unicode support in their header, so I kept the non-unicode portion as I doubt the borland compiler sets the compile option the if logic
in the header was using
Uh, "kept the non-unicode portion" ? The W versions are the Unicode
versions.
Don't have that header, so can't confirm or deny, but the structure
posted at the URL doesn't contain Any char or strings, so no Wide or
Narrow should exist (no A or W after the name).
Quote
>Did you run this (SHGetSetSettings) with FALSE to Read the values?
>Does that part work?

Yes, that is my GET program which dumps "something" perfectly to the screen. I now say something as I ran my GET program on a box without and shell setting tweaks and found it dumps the same data as
my tweaked PC... ggggrrrr!!!! I hate SDK's with 1) no samples and 2) just enough help to be 10% useless! ;-)
Then maybe you should repost that version over in nativeapi
 

Re:Progress with SHGetSetSettings function

Here's the part of the header that deals with this function...
////////////////////////////////////////////////////////////////////
//
// The shell keeps track of some per-user state to handle display
// options that is of major interest to ISVs.
// The key one requested right now is "DoubleClickInWebView".
typedef struct {
BOOL fShowAllObjects : 1;
BOOL fShowExtensions : 1;
BOOL fNoConfirmRecycle : 1;
BOOL fShowSysFiles : 1;
BOOL fShowCompColor : 1;
BOOL fDoubleClickInWebView : 1;
BOOL fDesktopHTML : 1;
BOOL fWin95Classic : 1;
BOOL fDontPrettyPath : 1;
BOOL fShowAttribCol : 1; // No longer used, dead bit
BOOL fMapNetDrvBtn : 1;
BOOL fShowInfoTip : 1;
BOOL fHideIcons : 1;
BOOL fWebView : 1;
BOOL fFilter : 1;
BOOL fShowSuperHidden : 1;
BOOL fNoNetCrawling : 1;
DWORD dwWin95Unused; // Win95 only - no longer supported pszHiddenFileExts
UINT uWin95Unused; // Win95 only - no longer supported cbHiddenFileExts
// Note: Not a typo! This is a persisted structure so we cannot use LPARAM
LONG lParamSort;
int iSortDirection;
UINT version;
// new for win2k. need notUsed var to calc the right size of ie4 struct
// FIELD_OFFSET does not work on bit fields
UINT uNotUsed; // feel free to rename and use
BOOL fSepProcess: 1;
// new for Whistler.
BOOL fStartPanelOn: 1; //Indicates if the Whistler StartPanel mode is ON or OFF.
BOOL fShowStartPage: 1; //Indicates if the Whistler StartPage on desktop is ON or OFF.
UINT fSpareFlags : 13;
} SHELLSTATEA, *LPSHELLSTATEA;
typedef struct {
BOOL fShowAllObjects : 1;
BOOL fShowExtensions : 1;
BOOL fNoConfirmRecycle : 1;
BOOL fShowSysFiles : 1;
BOOL fShowCompColor : 1;
BOOL fDoubleClickInWebView : 1;
BOOL fDesktopHTML : 1;
BOOL fWin95Classic : 1;
BOOL fDontPrettyPath : 1;
BOOL fShowAttribCol : 1;
BOOL fMapNetDrvBtn : 1;
BOOL fShowInfoTip : 1;
BOOL fHideIcons : 1;
BOOL fWebView : 1;
BOOL fFilter : 1;
BOOL fShowSuperHidden : 1;
BOOL fNoNetCrawling : 1;
DWORD dwWin95Unused; // Win95 only - no longer supported pszHiddenFileExts
UINT uWin95Unused; // Win95 only - no longer supported cbHiddenFileExts
// Note: Not a typo! This is a persisted structure so we cannot use LPARAM
LONG lParamSort;
int iSortDirection;
UINT version;
// new for win2k. need notUsed var to calc the right size of ie4 struct
// FIELD_OFFSET does not work on bit fields
UINT uNotUsed; // feel free to rename and use
BOOL fSepProcess: 1;
// new for Whistler.
BOOL fStartPanelOn: 1; //Indicates if the Whistler StartPage mode is ON or OFF.
BOOL fShowStartPage: 1; //Indicates if the Whistler StartPage on desktop is ON or OFF.
// If you need a new flag, steal a bit from from fSpareFlags.
UINT fSpareFlags : 13;
} SHELLSTATEW, *LPSHELLSTATEW;
#define SHELLSTATEVERSION_IE4 9
#define SHELLSTATEVERSION_WIN2K 10
#ifdef UNICODE
#define SHELLSTATE SHELLSTATEW
#define LPSHELLSTATE LPSHELLSTATEW
#else
#define SHELLSTATE SHELLSTATEA
#define LPSHELLSTATE LPSHELLSTATEA
#endif
#define SHELLSTATE_SIZE_WIN95 FIELD_OFFSET(SHELLSTATE,lParamSort)
#define SHELLSTATE_SIZE_NT4 FIELD_OFFSET(SHELLSTATE,version)
#define SHELLSTATE_SIZE_IE4 FIELD_OFFSET(SHELLSTATE,uNotUsed)
#define SHELLSTATE_SIZE_WIN2K sizeof(SHELLSTATE)
SHSTDAPI_(void) SHGetSetSettings(LPSHELLSTATE lpss, DWORD dwMask, BOOL bSet);
//
// SysFiles are these windows special files:
// "dll sys vxd 386 drv"
//
// hidden files are files with the FILE_ATTRIBUTE_HIDDEN attribute
//
// system files are files with the FILE_ATTRIBUTE_SYSTEM attribute
//
// fShowAllObjects fShowSysFiles Result
// --------------- ------------- ------
// 0 0 hide hidden + SysFiles + system files
// 0 1 hide hidden files.
// 1 0 show all files.
// 1 1 show all files.
//
typedef struct {
BOOL fShowAllObjects : 1;
BOOL fShowExtensions : 1;
BOOL fNoConfirmRecycle : 1;
BOOL fShowSysFiles : 1;
BOOL fShowCompColor : 1;
BOOL fDoubleClickInWebView : 1;
BOOL fDesktopHTML : 1;
BOOL fWin95Classic : 1;
BOOL fDontPrettyPath : 1;
BOOL fShowAttribCol : 1;
BOOL fMapNetDrvBtn : 1;
BOOL fShowInfoTip : 1;
BOOL fHideIcons : 1;
UINT fRestFlags : 3;
} SHELLFLAGSTATE, *LPSHELLFLAGSTATE;
#define SSF_SHOWALLOBJECTS 0x00000001
#define SSF_SHOWEXTENSIONS 0x00000002
#define SSF_HIDDENFILEEXTS 0x00000004
#define SSF_SERVERADMINUI 0x00000004
#define SSF_SHOWCOMPCOLOR 0x00000008
#define SSF_SORTCOLUMNS 0x00000010
#define SSF_SHOWSYSFILES 0x00000020
#define SSF_DOUBLECLICKINWEBVIEW 0x00000080
#define SSF_SHOWATTRIBCOL 0x00000100
#define SSF_DESKTOPHTML 0x00000200
#define SSF_WIN95CLASSIC 0x00000400
#define SSF_DONTPRETTYPATH 0x00000800
#define SSF_SHOWINFOTIP 0x00002000
#define SSF_MAPNETDRVBUTTON 0x00001000
#define SSF_NOCONFIRMRECYCLE 0x00008000
#define SSF_HIDEICONS 0x00004000
#define SSF_FILTER 0x00010000
#define SSF_WEBVIEW 0x00020000
#define SSF_SHOWSUPERHIDDEN 0x00040000
#define SSF_SEPPROCESS 0x00080000
#define SSF_NONETCRAWLING 0x00100000
#define SSF_STARTPANELON 0x00200000
#define SSF_SHOWSTARTPAGE 0x00400000
--
Michael Lueck
Lueck Data Systems
Remove the upper case letters NOSPAM to contact me directly.
 

Re:Progress with SHGetSetSettings function

Michael Lueck wrote:
Quote
Here's the part of the header that deals with this function...

typedef struct {
} SHELLSTATEA, *LPSHELLSTATEA;
typedef struct {
DWORD dwWin95Unused; // Win95 only - no longer supported pszHiddenFileExts
Ahh there it _was_ the reason for the A and W versions. A and W no
longer needed though, except to support explicit 95 code on newer
systems..
Quote
} SHELLSTATEW, *LPSHELLSTATEW;
#define SHELLSTATEVERSION_IE4 9
#define SHELLSTATEVERSION_WIN2K 10

#ifdef UNICODE
#define SHELLSTATE SHELLSTATEW
#define LPSHELLSTATE LPSHELLSTATEW
#else
#define SHELLSTATE SHELLSTATEA
#define LPSHELLSTATE LPSHELLSTATEA
#endif
You should use these defines as well, and not use the W version in
your app.
Quote
#define SHELLSTATE_SIZE_WIN95 FIELD_OFFSET(SHELLSTATE,lParamSort)
#define SHELLSTATE_SIZE_NT4 FIELD_OFFSET(SHELLSTATE,version)
#define SHELLSTATE_SIZE_IE4 FIELD_OFFSET(SHELLSTATE,uNotUsed)
#define SHELLSTATE_SIZE_WIN2K sizeof(SHELLSTATE)
Note: This isn't the best code in the world, just wanted to test
things out.
typedef void (_stdcall SHGETSetSettings)(LPSHELLSTATEA lpss, DWORD
dwMask, BOOL bSet);
SHELLSTATEA ssR = {0};
SHELLSTATEA ssW = {0};
SHELLSTATEA ssT = {0};
SHGETSetSettings *SHGetSetSettings;
int main(void)
{
HMODULE Dll = LoadLibrary("shell32.dll");
if( Dll )
{ SHGetSetSettings = (SHGETSetSettings*)GetProcAddress( Dll,
"SHGetSetSettings");
if( SHGetSetSettings )
{
ssR.version = SHELLSTATE_SIZE_WIN2K; /* try anything */
SHGetSetSettings(&ssR,-1,FALSE); /* get original */
ssW.fSpareFlags = 33;
SHGetSetSettings(&ssW,-1,TRUE); /* clear all */
SHGetSetSettings(&ssT,-1,FALSE); /* read what happened */
SHGetSetSettings(&ssR,-1,TRUE); /* reset to original */
SHGetSetSettings = NULL;
};
FreeLibrary( Dll );
};
return 0;
}
TD32 doesn't like executing the shell function. By going into CPU
view, single step into the shell routine, and placing breakpoints on
the second and third internal call, I was able to run the code in TD.
I'll try to clean up this screen dump for you.
Initial Read Write Test
-Inspecting ssR---- Inspecting ssW---- Inspecting ssT--------+
fShowAllObjects : 1 -1 ?0 ?0
fShowExtensions : 1 -1 ?0 ?0
fNoConfirmRecycle : 1 0 ?0 ?0
fShowSysFiles : 1 0 ?0 ?-1
fShowCompColor : 1 -1 ?0 ?0
fDoubleClickInWebView : 1 -1 ?0 ?0
fDesktopHTML : 1 0 ?0 ?0
fWin95Classic : 1 0 ?0 ?0
fDontPrettyPath : 1 0 ?0 ?0
fShowAttribCol : 1 0 ?0 ?0
fMapNetDrvBtn : 1 0 ?0 ?0
fShowInfoTip : 1 -1 ?0 ?0
fHideIcons : 1 0 ?0 ?0
fWebView : 1 -1 ?0 ?0
fFilter : 1 0 ?0 ?0
fShowSuperHidden : 1 -1 ?0 ?-1
fNoNetCrawling : 1 0 ?0 ?0
dwWin95Unused 0 (0x0) ?0 (0x0) ?0 (0x0)
uWin95Unused 0 (0x0) ?0 (0x0) ?0 (0x0)
lParamSort 0 (0x0) ?0 (0x0) ?0 (0x0)
iSortDirection 256 (0x100) ?0 (0x0) ?0 (0x0)
version 0 (0x0) ?0 (0x0) ?0 (0x0)
uNotUsed 0 (0x0) ?0 (0x0) ?0 (0x0)
fSepProcess : 1 0 ?0 ?0
fStartPanelOn : 1 0 ?0 ?0
fShowStartPage : 1 0 ?0 ?0
fSpareFlags : 13 32 ?33 ?32
Quote
SHSTDAPI_(void) SHGetSetSettings(LPSHELLSTATE lpss, DWORD dwMask, BOOL bSet);

//
// SysFiles are these windows special files:
// "dll sys vxd 386 drv"
//
// hidden files are files with the FILE_ATTRIBUTE_HIDDEN attribute
//
// system files are files with the FILE_ATTRIBUTE_SYSTEM attribute
//
// fShowAllObjects fShowSysFiles Result
// --------------- ------------- ------
// 0 0 hide hidden + SysFiles + system files
// 0 1 hide hidden files.
// 1 0 show all files.
// 1 1 show all files.
//
typedef struct {
BOOL fShowAllObjects : 1;
BOOL fShowExtensions : 1;
BOOL fNoConfirmRecycle : 1;
BOOL fShowSysFiles : 1;
BOOL fShowCompColor : 1;
BOOL fDoubleClickInWebView : 1;
BOOL fDesktopHTML : 1;
BOOL fWin95Classic : 1;
BOOL fDontPrettyPath : 1;
BOOL fShowAttribCol : 1;
BOOL fMapNetDrvBtn : 1;
BOOL fShowInfoTip : 1;
BOOL fHideIcons : 1;
UINT fRestFlags : 3;
} SHELLFLAGSTATE, *LPSHELLFLAGSTATE;

#define SSF_SHOWALLOBJECTS 0x00000001
#define SSF_SHOWEXTENSIONS 0x00000002
#define SSF_HIDDENFILEEXTS 0x00000004
#define SSF_SERVERADMINUI 0x00000004
#define SSF_SHOWCOMPCOLOR 0x00000008
#define SSF_SORTCOLUMNS 0x00000010
#define SSF_SHOWSYSFILES 0x00000020
#define SSF_DOUBLECLICKINWEBVIEW 0x00000080
#define SSF_SHOWATTRIBCOL 0x00000100
#define SSF_DESKTOPHTML 0x00000200
#define SSF_WIN95CLASSIC 0x00000400
#define SSF_DONTPRETTYPATH 0x00000800
#define SSF_SHOWINFOTIP 0x00002000
#define SSF_MAPNETDRVBUTTON 0x00001000
#define SSF_NOCONFIRMRECYCLE 0x00008000
#define SSF_HIDEICONS 0x00004000
#define SSF_FILTER 0x00010000
#define SSF_WEBVIEW 0x00020000
#define SSF_SHOWSUPERHIDDEN 0x00040000
#define SSF_SEPPROCESS 0x00080000
#define SSF_NONETCRAWLING 0x00100000
#define SSF_STARTPANELON 0x00200000
#define SSF_SHOWSTARTPAGE 0x00400000
 

Re:Progress with SHGetSetSettings function

Bob Gonder wrote:
Quote
TD32 doesn't like executing the shell function. By going into CPU
view, single step into the shell routine, and placing breakpoints on
the second and third internal call, I was able to run the code in TD.
The first of the 2 breakpoints is going into
NTDLL.RtlEnterCriticalSection
Don't know why, but TD seems to mess up when doing fancy things full
out. Can F7 though the whole thing just fine (in CPU mode).
Quote





>SHSTDAPI_(void) SHGetSetSettings(LPSHELLSTATE lpss, DWORD dwMask, BOOL bSet);
Rats, meant to delete alll that trailing stuffff...
 

Re:Progress with SHGetSetSettings function

Bob Gonder wrote:
Quote
Can F7 though the whole thing just fine (in CPU mode).
You say no GPF for you? Or no GPF only if you F7 through the code? (vs exe at the command line)
I switched over to the A version of the struct and renamed it minus the A as if the if statement had done so. Added the four defs / size, etc... as you suggested. Changed my CPP file to use the names
of these things without an A or W. Recompile, no behavior change on my side. Short of bugs in my code, is that roughly the list of ideas you had in your long posting?
Thanks!
--
Michael Lueck
Lueck Data Systems
Remove the upper case letters NOSPAM to contact me directly.
 

Re:Progress with SHGetSetSettings function

Michael Lueck wrote:
Quote
Bob Gonder wrote:

>Can F7 though the whole thing just fine (in CPU mode).

You say no GPF for you? Or no GPF only if you F7 through the code? (vs exe at the command line)
Well now, I hadn't tried to just run it, because I wouldn't have seen
the results. So, I just now executed it, and no GPF.
Quote
I switched over to the A version of the struct and renamed it minus the A as if the if statement had done so. Added the four defs / size, etc... as you suggested. Changed my CPP file to use the names
of these things without an A or W. Recompile, no behavior change on my side. Short of bugs in my code, is that roughly the list of ideas you had in your long posting?
The A and W versions are identical.
The 4 defs have no meaning for us that I can discern (They are the
struct sizes under different OSs, but we don't use size anywhere.)
My app was C not CPP.
Also, linked with noeh32.lib.
Take my code and try it for yourself, then start tweaking one bool
setting at a time until it no longer works.
Hmm.. left out the headers:
#include <Windows.h>
#include <shlobj.h>
typedef struct {
BOOL fShowAllObjects : 1;
etc.
 

Re:Progress with SHGetSetSettings function

Bob Gonder wrote:
Quote
typedef struct {
BOOL fShowAllObjects : 1;
etc.
Hang on there...
msdn.microsoft.com/library/default.asp
You mean that second param into the function needs to be a structure as well? I see there is a SHELLFLAGSTATE structure in the header, use that and not to add up the various defined constants for the
flags?
--
Michael Lueck
Lueck Data Systems
Remove the upper case letters NOSPAM to contact me directly.
 

Re:Progress with SHGetSetSettings function

Hi Bob-
Having a bit of fun trying to get your version to compile here.
Yes, using noeh32.lib in my makefile.mak
Compiler did not like the SHGetSetSettings function being being refined since it is already in the header, so dropped that line. Also didn't like you setting SHGetSetSettings = NULL; so I dropped that
line of code as well. Still ending up with two errors as follows:
Error E2141 SetShellSettings.cpp 9: Declaration syntax error
Error E2188 SetShellSettings.cpp 15: Expression syntax in function main()
Line 9 being SHGETSetSettings *SHGetSetSettings;
Line 15 being the GetProcAddress line which could be due to the Line 9 complaint.
I've again refreshed my header with the MS one, and hard coded:
#define SHELLSTATE SHELLSTATEA
#define LPSHELLSTATE LPSHELLSTATEA
without the if around them since I don't have unicode vars set.
Code currently as follows:
#include <iostream.h>
#include <windows.h>
#include "SetShellSettings.h"
SHELLSTATEA ssR = {0};
SHELLSTATEA ssW = {0};
SHELLSTATEA ssT = {0};
SHGETSetSettings *SHGetSetSettings;
int main(void)
{
HMODULE Dll = LoadLibrary("shell32.dll");
if( Dll ){
SHGetSetSettings = (SHGETSetSettings*)GetProcAddress( Dll, "SHGetSetSettings");
if( SHGetSetSettings ) {
ssR.version = SHELLSTATE_SIZE_WIN2K; /* try anything */
SHGetSetSettings(&ssR,-1,FALSE); /* get original */
ssW.fSpareFlags = 33;
SHGetSetSettings(&ssW,-1,TRUE); /* clear all */
SHGetSetSettings(&ssT,-1,FALSE); /* read what happened */
SHGetSetSettings(&ssR,-1,TRUE); /* reset to original */
/* SHGetSetSettings = NULL; */
};
FreeLibrary( Dll );
};
return 0;
}
One question short of the compile errors, why do you have the second param to the function always -1? Per the docs it seems that is suppose to identify which elements you want it to deal with, does -1
maybe tell it to do all? (Just a guess)
--
Michael Lueck
Lueck Data Systems
Remove the upper case letters NOSPAM to contact me directly.
 

Re:Progress with SHGetSetSettings function

Michael Lueck wrote:
Quote
Hang on there...
You mean that second param into the function needs to be a structure as well? I see there is a SHELLFLAGSTATE structure in the header, use that and not to add up the various defined constants for the
flags?
One could look at it that way....It's a struct of 32 bitflags.
Otherwise known as a DWORD.
Unfortunately, SHELLFLAGSTATE and dwMask don't align.
So, no, you can't use it for that.
If you look at my code, I used -1 for dwMask, to get and set all
available values.
 

Re:Progress with SHGetSetSettings function

Michael Lueck wrote:
Quote
Compiler did not like the SHGetSetSettings function being being refined since it is already in the header, so dropped that line. Also didn't like you setting SHGetSetSettings = NULL; so I dropped that
line of code as well. Still ending up with two errors as follows:
Well, put them back in. They are there for a purpose.
Instead, remove your header hacks.
In particular, remove the definition of SHGetSetSettings being an
external function, because it isn't.
Quote
One question short of the compile errors, why do you have the second param to the function always -1? Per the docs it seems that is suppose to identify which elements you want it to deal with, does -1
maybe tell it to do all? (Just a guess)
I didn't want to mess around writting a "real" program.