• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 914
  • Last Modified:

Change Windows XP Desktop Theme

Hi I want to change the Windows XP Desktop Theme with a Programme I'm writting, I have been unable to do so thus far. This is what I do know,

Theme management i.e. changing the theme is managed by ThemeUI.DLL located in System32. I found some Delphi code from another Experts Exchange question that works on XP Service Pack 1 and below but not on XP Service Pack 2. It is my belief that MS have either added some form of security or what appears to be the more likely answer is that they have simply changed the Function calls within the DLL. They are able to do this because ThemeUI.DLL has not had it's Functions published by MS the reason for this I'm assuming is the same reason given for not allowing completely customized themes for XP (They apparently where worried about application compatibility). See Delphi code on the following link...

http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_21172764.html

I do not wish to change the Theme Style I only want to provide users in our Corporate Environment with the ability to be able to change thier Desktop theme while only using company approved themes. Please don't go down the path of suggesting Group Policy or registry changes as GP only locks down the Themes dialogue tab which we will be doing upon Rollout of XP and the registry changes require Explorer.exe to be restarted and there are only 2 ways to do this the prefered way being to reboot the PC.

I have posted this question in different forms on different forums on Experts Exchange and I rather desperate for an answer I know among one of you there will be someone with the knowledge I seek. If you can answer this question feel free to go to the other questions and post the same answer I'll gladly give over the 500 points each is worth and a grade of A... See below some links to the questions I have posted and possibly more information.

http://www.experts-exchange.com/Programming/Q_21402283.html
http://www.experts-exchange.com/Programming/Q_21398325.html
http://www.experts-exchange.com/Operating_Systems/Q_21396782.html   
0
Haggard1
Asked:
Haggard1
  • 3
  • 2
1 Solution
 
Russell LibbySoftware Engineer, Advisory Commented:

As the author of the original posting, I thought I should take a look to see what happened between XP sp1 and sp2.

Well, what can I say but "thank you M$, for being the wonderful (** pick your word **) that you are". In their greatness, they decided that if you attempt to do anything IDispatch based (automation) against this AX interface, then the only thing they will allow you to do is call GetSelectedSchemeProperty. Importing the type library yields a single IDispatch interface with a single method call. Scanning the themeui.dll with a binary editor yeilded little else.

So, I got the sp1 themeui.dll and imported the type info it, then using the clsid/iid for the original interface, lo and behold... it all still works against the NEW themeui.dll. ;-). You will just need to include the type info unit that I am including, and always remember to use the Vtable bound interfaces (no IDispatch).

If you have further problems then please ask.

Regards,
Russell

------------------

Source first, then unit to include (done in D5)...


unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, ComObj, ActiveX, Theme_TLB;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation
{$R *.DFM}

const
  CLASS_ThemeManager:  TGUID =  '{2E17C0EF-2851-459B-A3C8-27A41D4BC9F7}';
  IID_IThemeManager:   TGUID =  '{04D5D56C-EEAF-4419-B786-300284D6BB5F}';

procedure TForm1.Button1Click(Sender: TObject);
var  pvTM:          IThemeManager;
     pvTheme:       ITheme;
     dwThemes:      Integer;
     dwTheme:       Integer;
begin

  // Such a hack....
  if (CoCreateInstance(CLASS_ThemeManager, nil, CLSCTX_ALL, IID_IThemeManager, pvTM) = S_OK) then
  begin
     // Resource protection
     try
        // Get the count of themes
        dwThemes:=Pred(pvTM.Length);
        // Walk the items looking for the classic style
        for dwTheme:=0 to dwThemes do
        begin
           // Get the theme
           pvTheme:=pvTM.Item[dwTheme];
           try
              // Check the theme name
              if (CompareText(String(pvTheme.DisplayName), 'Windows Classic') = 0) then
              begin
                 // Set the theme
                 pvTM.SelectedTheme:=pvTheme;
                 // Apply the theme
                 pvTM.ApplyNow;
                 // Done
                 break;
              end;
           finally
              // Release the theme
              pvTheme:=nil;
           end;
        end;
     finally
        // Release the theme manager interface
        pvTM:=nil;
     end;
  end;

end;

end.

------------------------------ Theme_tlb.pas -------------------------------

unit Theme_TLB;

{$TYPEDADDRESS OFF} // Unit must be compiled without type-checked pointers.
interface

uses Windows, ActiveX;

const
  // TypeLibrary Major and minor versions
  ThemeMajorVersion = 1;
  ThemeMinorVersion = 0;

  LIBID_Theme: TGUID = '{40643250-8D23-47FB-895C-EAF48E2C8892}';

  IID_ITheme: TGUID = '{A41C22EB-0F93-40AE-B7CE-37A4C4C81B01}';
  IID_IThemeScheme: TGUID = '{AA49D906-65B2-42D6-A26A-2EE03C83F839}';
  IID_IThemeStyle: TGUID = '{3672E804-D69D-43D8-AF58-F320B8D9AF32}';
  IID_IThemeSize: TGUID = '{72DD2E7F-21E5-46DC-8847-CDDCF58B6725}';
  IID_IThemeManager: TGUID = '{04D5D56C-EEAF-4419-B786-300284D6BB5F}';
  CLASS_ThemeManager: TGUID = '{2E17C0EF-2851-459B-A3C8-27A41D4BC9F7}';
  CLASS_Theme_: TGUID = '{F60691B4-3BD8-4F42-B2FD-20853C433A74}';
  CLASS_ThemeScheme: TGUID = '{1C995F92-244F-48AC-9784-4AF9586EBBBA}';
  CLASS_ThemeStyle: TGUID = '{AFCEFAC8-8097-4EE5-82DF-121202D95342}';
  CLASS_ThemeSize: TGUID = '{05AF76AC-4245-468F-AE35-6D233436937A}';
  IID_IThemePreview: TGUID = '{B63705F2-B2A2-401E-A20D-643E6B554A1D}';
  IID_IPropertyBag: TGUID = '{55272A00-42CB-11CE-8135-00AA004BB851}';
  IID_IErrorLog: TGUID = '{3127CA40-446E-11CE-8135-00AA004BB851}';
  CLASS_ThemePreview: TGUID = '{B7BBD408-F09C-4AA8-B65E-A00B8FE0F0B9}';

// *********************************************************************//
// Declaration of Enumerations defined in Type Library                    
// *********************************************************************//
// Constants for enum __MIDL_ITheme_0001
type
  __MIDL_ITheme_0001 = TOleEnum;
const
  BKDGT_CENTER = $00000000;
  BKDGT_TILE = $00000001;
  BKDGT_STRECH = $00000002;

// Constants for enum __MIDL_IThemeSize_0002
type
  __MIDL_IThemeSize_0002 = TOleEnum;
const
  SMS_BORDERWIDTH = $00000000;
  SMS_SCROLLWIDTH = $00000001;
  SMS_SCROLLHEIGHT = $00000002;
  SMS_CAPTIONWIDTH = $00000003;
  SMS_CAPTIONHEIGHT = $00000004;
  SMS_SMCAPTIONWIDTH = $00000005;
  SMS_SMCAPTIONHEIGHT = $00000006;
  SMS_MENUWIDTH = $00000007;
  SMS_MENUHEIGHT = $00000008;

// Constants for enum __MIDL_IThemeSize_0003
type
  __MIDL_IThemeSize_0003 = TOleEnum;
const
  CONTRAST_NORMAL = $00000000;
  CONTRAST_HIGHBLACK = $00000001;
  CONTRAST_HIGHWHITE = $00000002;

// Constants for enum __MIDL_IThemeSize_0001
type
  __MIDL_IThemeSize_0001 = TOleEnum;
const
  SMF_CAPTIONFONT = $00000000;
  SMF_SMCAPTIONFONT = $00000001;
  SMF_MENUFONT = $00000002;
  SMF_ICONTITLEFONT = $00000003;
  SMF_STATUSFONT = $00000004;
  SMF_MESSAGEFONT = $00000005;

type

// *********************************************************************//
// Forward declaration of types defined in TypeLibrary                    
// *********************************************************************//
  ITheme = interface;
  IThemeDisp = dispinterface;
  IThemeScheme = interface;
  IThemeSchemeDisp = dispinterface;
  IThemeStyle = interface;
  IThemeStyleDisp = dispinterface;
  IThemeSize = interface;
  IThemeSizeDisp = dispinterface;
  IThemeManager = interface;
  IThemeManagerDisp = dispinterface;
  IThemePreview = interface;
  IThemePreviewDisp = dispinterface;
  IPropertyBag = interface;
  IErrorLog = interface;

// *********************************************************************//
// Declaration of CoClasses defined in Type Library                      
// (NOTE: Here we map each CoClass to its Default Interface)              
// *********************************************************************//
  ThemeManager = IThemeManager;
  Theme_ = ITheme;
  ThemeScheme = IThemeScheme;
  ThemeStyle = IThemeStyle;
  ThemeSize = IThemeSize;
  ThemePreview = IThemePreview;


// *********************************************************************//
// Declaration of structures, unions and aliases.                        
// *********************************************************************//
  wireHWND = ^TGUID;
  PUserType1 = ^LOGFONTW; {*}
  POleVariant1 = ^OleVariant; {*}
  PUserType2 = ^TGUID; {*}

  enumBkgdTile = __MIDL_ITheme_0001;
  enumSystemMetricSize = __MIDL_IThemeSize_0002;
  enumThemeContrastLevels = __MIDL_IThemeSize_0003;
  enumSystemMetricFont = __MIDL_IThemeSize_0001;

  __MIDL___MIDL_itf_theme_0253_0004 = packed record
    lfHeight: Integer;
    lfWidth: Integer;
    lfEscapement: Integer;
    lfOrientation: Integer;
    lfWeight: Integer;
    lfItalic: Byte;
    lfUnderline: Byte;
    lfStrikeOut: Byte;
    lfCharSet: Byte;
    lfOutPrecision: Byte;
    lfClipPrecision: Byte;
    lfQuality: Byte;
    lfPitchAndFamily: Byte;
    lfFaceName: array[0..31] of Word;
  end;

  LOGFONTW = TGUID;

  __MIDL_IWinTypes_0009 = record
    case Integer of
      0: (hInproc: Integer);
      1: (hRemote: Integer);
  end;

  _RemotableHandle = packed record
    fContext: Integer;
    u: __MIDL_IWinTypes_0009;
  end;


// *********************************************************************//
// Interface: ITheme
// Flags:     (4544) Dual NonExtensible OleAutomation Dispatchable
// GUID:      {A41C22EB-0F93-40AE-B7CE-37A4C4C81B01}
// *********************************************************************//
  ITheme = interface(IDispatch)
    ['{A41C22EB-0F93-40AE-B7CE-37A4C4C81B01}']
    function  Get_DisplayName: WideString; safecall;
    procedure Set_DisplayName(const pbstrDisplayName: WideString); safecall;
    function  Get_Background: WideString; safecall;
    procedure Set_Background(const pbstrPath: WideString); safecall;
    function  Get_BackgroundTile: enumBkgdTile; safecall;
    procedure Set_BackgroundTile(pnTile: enumBkgdTile); safecall;
    function  Get_ScreenSaver: WideString; safecall;
    procedure Set_ScreenSaver(const pbstrPath: WideString); safecall;
    function  Get_VisualStyle: WideString; safecall;
    procedure Set_VisualStyle(const pbstrPath: WideString); safecall;
    function  Get_VisualStyleColor: WideString; safecall;
    procedure Set_VisualStyleColor(const pbstrPath: WideString); safecall;
    function  Get_VisualStyleSize: WideString; safecall;
    procedure Set_VisualStyleSize(const pbstrPath: WideString); safecall;
    function  GetPath(fExpand: WordBool): WideString; safecall;
    procedure SetPath(const bstrPath: WideString); safecall;
    function  GetCursor(const bstrCursor: WideString): WideString; safecall;
    procedure SetCursor(const bstrCursor: WideString; const bstrPath: WideString); safecall;
    function  GetSound(const bstrSoundName: WideString): WideString; safecall;
    procedure SetSound(const bstrSoundName: WideString; const bstrPath: WideString); safecall;
    function  GetIcon(const bstrIconName: WideString): WideString; safecall;
    procedure SetIcon(const bstrIconName: WideString; const bstrIconPath: WideString); safecall;
    property DisplayName: WideString read Get_DisplayName write Set_DisplayName;
    property Background: WideString read Get_Background write Set_Background;
    property BackgroundTile: enumBkgdTile read Get_BackgroundTile write Set_BackgroundTile;
    property ScreenSaver: WideString read Get_ScreenSaver write Set_ScreenSaver;
    property VisualStyle: WideString read Get_VisualStyle write Set_VisualStyle;
    property VisualStyleColor: WideString read Get_VisualStyleColor write Set_VisualStyleColor;
    property VisualStyleSize: WideString read Get_VisualStyleSize write Set_VisualStyleSize;
  end;

// *********************************************************************//
// DispIntf:  IThemeDisp
// Flags:     (4544) Dual NonExtensible OleAutomation Dispatchable
// GUID:      {A41C22EB-0F93-40AE-B7CE-37A4C4C81B01}
// *********************************************************************//
  IThemeDisp = dispinterface
    ['{A41C22EB-0F93-40AE-B7CE-37A4C4C81B01}']
    property DisplayName: WideString dispid 200;
    property Background: WideString dispid 201;
    property BackgroundTile: enumBkgdTile dispid 202;
    property ScreenSaver: WideString dispid 203;
    property VisualStyle: WideString dispid 252;
    property VisualStyleColor: WideString dispid 253;
    property VisualStyleSize: WideString dispid 254;
    function  GetPath(fExpand: WordBool): WideString; dispid 250;
    procedure SetPath(const bstrPath: WideString); dispid 251;
    function  GetCursor(const bstrCursor: WideString): WideString; dispid 255;
    procedure SetCursor(const bstrCursor: WideString; const bstrPath: WideString); dispid 256;
    function  GetSound(const bstrSoundName: WideString): WideString; dispid 257;
    procedure SetSound(const bstrSoundName: WideString; const bstrPath: WideString); dispid 258;
    function  GetIcon(const bstrIconName: WideString): WideString; dispid 259;
    procedure SetIcon(const bstrIconName: WideString; const bstrIconPath: WideString); dispid 260;
  end;

// *********************************************************************//
// Interface: IThemeScheme
// Flags:     (4544) Dual NonExtensible OleAutomation Dispatchable
// GUID:      {AA49D906-65B2-42D6-A26A-2EE03C83F839}
// *********************************************************************//
  IThemeScheme = interface(IDispatch)
    ['{AA49D906-65B2-42D6-A26A-2EE03C83F839}']
    function  Get_DisplayName: WideString; safecall;
    procedure Set_DisplayName(const pbstrDisplayName: WideString); safecall;
    function  Get_Path: WideString; safecall;
    procedure Set_Path(const pbstrPath: WideString); safecall;
    function  Get_length: Integer; safecall;
    function  Get_item(varIndex: OleVariant): IThemeStyle; safecall;
    function  Get_SelectedStyle: IThemeStyle; safecall;
    procedure Set_SelectedStyle(const ppThemeStyle: IThemeStyle); safecall;
    function  AddStyle: IThemeStyle; safecall;
    property DisplayName: WideString read Get_DisplayName write Set_DisplayName;
    property Path: WideString read Get_Path write Set_Path;
    property length: Integer read Get_length;
    property item[varIndex: OleVariant]: IThemeStyle read Get_item;
    property SelectedStyle: IThemeStyle read Get_SelectedStyle write Set_SelectedStyle;
  end;

// *********************************************************************//
// DispIntf:  IThemeSchemeDisp
// Flags:     (4544) Dual NonExtensible OleAutomation Dispatchable
// GUID:      {AA49D906-65B2-42D6-A26A-2EE03C83F839}
// *********************************************************************//
  IThemeSchemeDisp = dispinterface
    ['{AA49D906-65B2-42D6-A26A-2EE03C83F839}']
    property DisplayName: WideString dispid 301;
    property Path: WideString dispid 302;
    property length: Integer readonly dispid 303;
    property item[varIndex: OleVariant]: IThemeStyle readonly dispid 304;
    property SelectedStyle: IThemeStyle dispid 305;
    function  AddStyle: IThemeStyle; dispid 350;
  end;

// *********************************************************************//
// Interface: IThemeStyle
// Flags:     (4544) Dual NonExtensible OleAutomation Dispatchable
// GUID:      {3672E804-D69D-43D8-AF58-F320B8D9AF32}
// *********************************************************************//
  IThemeStyle = interface(IDispatch)
    ['{3672E804-D69D-43D8-AF58-F320B8D9AF32}']
    function  Get_DisplayName: WideString; safecall;
    procedure Set_DisplayName(const pbstrDisplayName: WideString); safecall;
    function  Get_Name: WideString; safecall;
    procedure Set_Name(const pbstrName: WideString); safecall;
    function  Get_length: Integer; safecall;
    function  Get_item(varIndex: OleVariant): IThemeSize; safecall;
    function  Get_SelectedSize: IThemeSize; safecall;
    procedure Set_SelectedSize(const ppThemeSize: IThemeSize); safecall;
    function  AddSize: IThemeSize; safecall;
    property DisplayName: WideString read Get_DisplayName write Set_DisplayName;
    property Name: WideString read Get_Name write Set_Name;
    property length: Integer read Get_length;
    property item[varIndex: OleVariant]: IThemeSize read Get_item;
    property SelectedSize: IThemeSize read Get_SelectedSize write Set_SelectedSize;
  end;

// *********************************************************************//
// DispIntf:  IThemeStyleDisp
// Flags:     (4544) Dual NonExtensible OleAutomation Dispatchable
// GUID:      {3672E804-D69D-43D8-AF58-F320B8D9AF32}
// *********************************************************************//
  IThemeStyleDisp = dispinterface
    ['{3672E804-D69D-43D8-AF58-F320B8D9AF32}']
    property DisplayName: WideString dispid 400;
    property Name: WideString dispid 401;
    property length: Integer readonly dispid 402;
    property item[varIndex: OleVariant]: IThemeSize readonly dispid 403;
    property SelectedSize: IThemeSize dispid 404;
    function  AddSize: IThemeSize; dispid 450;
  end;

// *********************************************************************//
// Interface: IThemeSize
// Flags:     (4544) Dual NonExtensible OleAutomation Dispatchable
// GUID:      {72DD2E7F-21E5-46DC-8847-CDDCF58B6725}
// *********************************************************************//
  IThemeSize = interface(IDispatch)
    ['{72DD2E7F-21E5-46DC-8847-CDDCF58B6725}']
    function  Get_DisplayName: WideString; safecall;
    procedure Set_DisplayName(const pbstrDisplayName: WideString); safecall;
    function  Get_Name: WideString; safecall;
    procedure Set_Name(const pbstrName: WideString); safecall;
    function  Get_SystemMetricColor(nSysColorIndex: SYSINT): LongWord; safecall;
    procedure Set_SystemMetricColor(nSysColorIndex: SYSINT; pColorRef: LongWord); safecall;
    function  Get_SystemMetricSize(nSystemMetricIndex: enumSystemMetricSize): SYSINT; safecall;
    procedure Set_SystemMetricSize(nSystemMetricIndex: enumSystemMetricSize; pnSize: SYSINT); safecall;
    function  Get_WebviewCSS: WideString; safecall;
    function  Get_ContrastLevel: enumThemeContrastLevels; safecall;
    procedure Set_ContrastLevel(pContrastLevel: enumThemeContrastLevels); safecall;
    procedure GetSystemMetricFont(nFontIndex: enumSystemMetricFont; var pLogFontW: LOGFONTW); safecall;
    procedure PutSystemMetricFont(nFontIndex: enumSystemMetricFont; var pLogFontW: LOGFONTW); safecall;
    property DisplayName: WideString read Get_DisplayName write Set_DisplayName;
    property Name: WideString read Get_Name write Set_Name;
    property SystemMetricColor[nSysColorIndex: SYSINT]: LongWord read Get_SystemMetricColor write Set_SystemMetricColor;
    property SystemMetricSize[nSystemMetricIndex: enumSystemMetricSize]: SYSINT read Get_SystemMetricSize write Set_SystemMetricSize;
    property WebviewCSS: WideString read Get_WebviewCSS;
    property ContrastLevel: enumThemeContrastLevels read Get_ContrastLevel write Set_ContrastLevel;
  end;

// *********************************************************************//
// DispIntf:  IThemeSizeDisp
// Flags:     (4544) Dual NonExtensible OleAutomation Dispatchable
// GUID:      {72DD2E7F-21E5-46DC-8847-CDDCF58B6725}
// *********************************************************************//
  IThemeSizeDisp = dispinterface
    ['{72DD2E7F-21E5-46DC-8847-CDDCF58B6725}']
    property DisplayName: WideString dispid 500;
    property Name: WideString dispid 501;
    property SystemMetricColor[nSysColorIndex: SYSINT]: LongWord dispid 502;
    property SystemMetricSize[nSystemMetricIndex: enumSystemMetricSize]: SYSINT dispid 503;
    property WebviewCSS: WideString readonly dispid 504;
    property ContrastLevel: enumThemeContrastLevels dispid 505;
    procedure GetSystemMetricFont(nFontIndex: enumSystemMetricFont;
                                  var pLogFontW: {??LOGFONTW} OleVariant); dispid 550;
    procedure PutSystemMetricFont(nFontIndex: enumSystemMetricFont;
                                  var pLogFontW: {??LOGFONTW} OleVariant); dispid 551;
  end;

// *********************************************************************//
// Interface: IThemeManager
// Flags:     (4544) Dual NonExtensible OleAutomation Dispatchable
// GUID:      {04D5D56C-EEAF-4419-B786-300284D6BB5F}
// *********************************************************************//
  IThemeManager = interface(IDispatch)
    ['{04D5D56C-EEAF-4419-B786-300284D6BB5F}']
    function  Get_length: Integer; safecall;
    function  Get_item(varIndex: OleVariant): ITheme; safecall;
    function  Get_schemeLength: Integer; safecall;
    function  Get_schemeItem(varIndex: OleVariant): IThemeScheme; safecall;
    function  Get_WebviewCSS: WideString; safecall;
    function  Get_SelectedTheme: ITheme; safecall;
    procedure Set_SelectedTheme(const ppTheme: ITheme); safecall;
    function  Get_SelectedScheme: IThemeScheme; safecall;
    procedure Set_SelectedScheme(const ppThemeScheme: IThemeScheme); safecall;
    function  GetSpecialTheme(const bstrName: WideString): ITheme; safecall;
    procedure SetSpecialTheme(const bstrName: WideString; const pTheme: ITheme); safecall;
    function  GetSpecialScheme(const bstrName: WideString; out ppThemeScheme: IThemeScheme;
                               out ppThemeStyle: IThemeStyle): IThemeSize; safecall;
    procedure SetSpecialScheme(const bstrName: WideString; const pThemeScheme: IThemeScheme;
                               const pThemeStyle: IThemeStyle; const pThemeSize: IThemeSize); safecall;
    function  GetSelectedSchemeProperty(const bstrName: WideString): WideString; safecall;
    procedure ApplyNow; safecall;
    property length: Integer read Get_length;
    property item[varIndex: OleVariant]: ITheme read Get_item;
    property schemeLength: Integer read Get_schemeLength;
    property schemeItem[varIndex: OleVariant]: IThemeScheme read Get_schemeItem;
    property WebviewCSS: WideString read Get_WebviewCSS;
    property SelectedTheme: ITheme read Get_SelectedTheme write Set_SelectedTheme;
    property SelectedScheme: IThemeScheme read Get_SelectedScheme write Set_SelectedScheme;
  end;

// *********************************************************************//
// DispIntf:  IThemeManagerDisp
// Flags:     (4544) Dual NonExtensible OleAutomation Dispatchable
// GUID:      {04D5D56C-EEAF-4419-B786-300284D6BB5F}
// *********************************************************************//
  IThemeManagerDisp = dispinterface
    ['{04D5D56C-EEAF-4419-B786-300284D6BB5F}']
    property length: Integer readonly dispid 101;
    property item[varIndex: OleVariant]: ITheme readonly dispid 102;
    property schemeLength: Integer readonly dispid 105;
    property schemeItem[varIndex: OleVariant]: IThemeScheme readonly dispid 106;
    property WebviewCSS: WideString readonly dispid 104;
    property SelectedTheme: ITheme dispid 100;
    property SelectedScheme: IThemeScheme dispid 103;
    function  GetSpecialTheme(const bstrName: WideString): ITheme; dispid 151;
    procedure SetSpecialTheme(const bstrName: WideString; const pTheme: ITheme); dispid 152;
    function  GetSpecialScheme(const bstrName: WideString; out ppThemeScheme: IThemeScheme;
                               out ppThemeStyle: IThemeStyle): IThemeSize; dispid 153;
    procedure SetSpecialScheme(const bstrName: WideString; const pThemeScheme: IThemeScheme;
                               const pThemeStyle: IThemeStyle; const pThemeSize: IThemeSize); dispid 154;
    function  GetSelectedSchemeProperty(const bstrName: WideString): WideString; dispid 150;
    procedure ApplyNow; dispid 155;
  end;

// *********************************************************************//
// Interface: IThemePreview
// Flags:     (448) Dual NonExtensible OleAutomation
// GUID:      {B63705F2-B2A2-401E-A20D-643E6B554A1D}
// *********************************************************************//
  IThemePreview = interface(IUnknown)
    ['{B63705F2-B2A2-401E-A20D-643E6B554A1D}']
    procedure UpdatePreview(const pPropertyBag: IPropertyBag); safecall;
    procedure CreatePreview(var hwndParent: TGUID; dwFlags: LongWord; dwStyle: LongWord;
                            dwExStyle: LongWord; x: SYSINT; y: SYSINT; nWidth: SYSINT;
                            nHeight: SYSINT; const pPropertyBag: IPropertyBag; dwCtrlID: LongWord); safecall;
  end;

// *********************************************************************//
// DispIntf:  IThemePreviewDisp
// Flags:     (448) Dual NonExtensible OleAutomation
// GUID:      {B63705F2-B2A2-401E-A20D-643E6B554A1D}
// *********************************************************************//
  IThemePreviewDisp = dispinterface
    ['{B63705F2-B2A2-401E-A20D-643E6B554A1D}']
    procedure UpdatePreview(const pPropertyBag: IPropertyBag); dispid 650;
    procedure CreatePreview(var hwndParent: {??TGUID} OleVariant; dwFlags: LongWord;
                            dwStyle: LongWord; dwExStyle: LongWord; x: SYSINT; y: SYSINT;
                            nWidth: SYSINT; nHeight: SYSINT; const pPropertyBag: IPropertyBag;
                            dwCtrlID: LongWord); dispid 651;
  end;

// *********************************************************************//
// Interface: IPropertyBag
// Flags:     (0)
// GUID:      {55272A00-42CB-11CE-8135-00AA004BB851}
// *********************************************************************//
  IPropertyBag = interface(IUnknown)
    ['{55272A00-42CB-11CE-8135-00AA004BB851}']
    function  RemoteRead(pszPropName: PWideChar; out pVar: OleVariant; const pErrorLog: IErrorLog;
                         varType: LongWord; const pUnkObj: IUnknown): HResult; stdcall;
    function  Write(pszPropName: PWideChar; var pVar: OleVariant): HResult; stdcall;
  end;

// *********************************************************************//
// Interface: IErrorLog
// Flags:     (0)
// GUID:      {3127CA40-446E-11CE-8135-00AA004BB851}
// *********************************************************************//
  IErrorLog = interface(IUnknown)
    ['{3127CA40-446E-11CE-8135-00AA004BB851}']
    function  AddError(pszPropName: PWideChar; var pExcepInfo: TGUID): HResult; stdcall;
  end;

implementation

end.
0
 
Russell LibbySoftware Engineer, Advisory Commented:
Btw... my code comments of

  // Such a hack....
  if (CoCreateInstance(CLASS_ThemeManager, nil, CLSCTX_ALL, IID_IThemeManager, pvTM) = S_OK) then
  begin

is in no way reference of the code provided, only the fact that we have to do these hoops to use something that MS$ won't doc, and decides to change at their own discretion. This code WILL run on XP, sp1, and sp2.

Russell

0
 
Haggard1Author Commented:
Thankyou so much for your help,

Could you help me with a couple of points?

1. My Delphi sucks and I was wondering if you could help me convert your code into VB or C#? (Prefer VB)

2. How did you manage to retrieve the Functions from the DLL I've been trying for weeks now with no success at all?

I have several other posts about this topic they are shown as links in my original question above if you like you can post a link in those questions and I'll accept them for you so you get the points...

You deffinately deserver them.

Thanks again

Haggard
0
 
Russell LibbySoftware Engineer, Advisory Commented:
Haggard,

This is the Delphi TA, and I only mention this because I know delphi (and C/ASM) and tend to stick with what I know, if you follow my drift.... meaning I really can't help you with the C#/VB aspect of this.  I just don't have a good enough knowledge of those languages....

I can tell you what I did though.. (should apply to other languages as well)

1.) First, get hold of the themeui.dll from non SP2 version of XP (XP or sp1 version) and place it on your drive somewhere.
2.) Import the type library from this dll. It contains all the exposed interfaces and methods that you need to work with. These interfaces are retrievable from the latest (sp2) dll, but are not exposed via the current type library info.
3.) Include the type info with your project, then use the early bound interfaces. I *think* in VB, it is something like

dim objTheme as IThemeManager

but don't quote me, as I am NO VB expert. I don't wish to accept the other question points; in fact, it would probably be better (for you as well) to get someone to translate the above information to the language that you desire. It just boils down to using the type info from the OLD dll and making sure to use early bound (vtable) interfaces, vs the late bound (IDispatch) interfaces.

Hope this helps you further along.
Russsell





0
 
Haggard1Author Commented:
Thanks again Russell,

Will do

Cheers
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now