S
SuperSheep
Guest
Didn't know if I should post this here or in the Active Desktop Tutorial thread but as that thread is getting mighty long, I thought this would stand a better chance of getting seen here.
I've been digging into different ways of accessing various things like Control Panel items, Drives, and such and have finally found a miraculous new way, Namespaces. Try this code out for yourself and you be the judge...
Just copy & paste into notepad and save as test.html or whatever you prefer and see the power of Namespaces. I decided to write a single function to populate the listboxes as well as run the items to make it even more efficient.
Questions & Comments are welcome.
I've been digging into different ways of accessing various things like Control Panel items, Drives, and such and have finally found a miraculous new way, Namespaces. Try this code out for yourself and you be the judge...
Code:
<HTML><HEAD><TITLE></TITLE>
<SCRIPT LANGUAGE="JavaScript">
// System Constants
var ssfDESKTOP = 0; // Windows Desktop
var ssfPROGRAMS = 0x2; // User's program groups
var ssfCONTROLS = 0x3; // Icons for the Control Panel applications
var ssfPRINTERS = 0x4; // Installed printers
var ssfPERSONAL = 0x5; // User's documents
var ssfFAVORITES = 0x6; // User's favorite items
var ssfSTARTUP = 0x7; // User's Startup program group
var ssfRECENT = 0x8; // User's most recently used documents
var ssfSENDTO = 0x9; // Send To menu items
var ssfBITBUCKET = 0xa; // Recycle Bin
var ssfSTARTMENU = 0xb; // Directory containing Start menu items
var ssfDESKTOPDIRECTORY = 0x10; // File objects that are displayed on the desktop
var ssfDRIVES = 0x11; // My Computer
var ssfNETWORK = 0x12; // Network Neighborhood
var ssfNETHOOD = 0x13; // Link objects that may exist in the My Network Places
var ssfFONTS = 0x14; // Installed fonts
var ssfTEMPLATES = 0x15; // Document templates
var ssfCOMMONSTARTMENU = 0x16; // Programs and folders that appear on Start menu for all users
var ssfCOMMONPROGRAMS = 0x17; // Directories for common program groups that appear on Start menu for all users
var ssfCOMMONSTARTUP = 0x18; // Programs that appear in the Startup folder for all users
var ssfCOMMONDESKTOPDIR = 0x19; // Files and folders that appear on the desktop for all users
var ssfAPPDATA = 0x1a; // Application-specific data
var ssfPRINTHOOD = 0x1b; // Link objects that may exist in the Printers virtual folder
var ssfLOCALAPPDATA = 0x1c; // Local (non-roaming) applications
var ssfALTSTARTUP = 0x1d; // User's nonlocalized Startup program group
var ssfCOMMONALTSTARTUP = 0x1e; // Nonlocalized Startup program group for all users
var ssfCOMMONFAVORITES = 0x1f; // All users' favorite items
var ssfINTERNETCACHE = 0x20; // Temporary Internet files
var ssfCOOKIES = 0x21; // Internet cookies
var ssfHISTORY = 0x22; // Internet history items
var ssfCOMMONAPPDATA = 0x23; // Application data for all users
var ssfWINDOWS = 0x24; // Windows directory or SYSROOT
var ssfSYSTEM = 0x25; // System folder
var ssfPROGRAMFILES = 0x26; // Program Files folder
var ssfMYPICTURES = 0x27; // My Pictures folder
var ssfPROFILE = 0x28; // User's profile folder
// Variables
var sa = new ActiveXObject("Shell.Application");
var ssf = new Array(0x28);
function PopulateAll() {
Populate(ssfCONTROLS, 'ocpanel');
Populate(ssfDRIVES, 'odrives');
Populate(ssfFONTS, 'ofonts');
Populate(ssfMYPICTURES, 'omypictures');
}
function Populate(ssfItem,cID) {
ssf[ssfItem] = new Object(sa.NameSpace(ssfItem));
var ssfItems = new Object(ssf[ssfItem].Items());
eval("document.all."+cID+".Name=ssfItem");
for(i=0; i<ssfItems.Count; i++) {
var oOption = document.createElement("OPTION");
oOption.text = ssfItems.Item(i).Name;
eval("document.all."+cID+".add(oOption)");
}
}
function RunSpecial(ssfItem, index) {
var ssfItems = new Object(ssf[ssfItem].Items());
ssfItems.Item(index).InvokeVerb();
}
</SCRIPT>
</HEAD>
<BODY ONLOAD="PopulateAll()">
<FORM>
<SELECT ID="ocpanel" SIZE="10"
ONDBLCLICK="RunSpecial(this.Name, this.selectedIndex)"></SELECT>
<SELECT ID="odrives" SIZE="10"
ONDBLCLICK="RunSpecial(this.Name, this.selectedIndex)"></SELECT>
<SELECT ID="ofonts" SIZE="10"
ONDBLCLICK="RunSpecial(this.Name, this.selectedIndex)"></SELECT>
<SELECT ID="omypictures" SIZE="10"
ONDBLCLICK="RunSpecial(this.Name, this.selectedIndex)"></SELECT>
</FORM>
</BODY></HTML>
Just copy & paste into notepad and save as test.html or whatever you prefer and see the power of Namespaces. I decided to write a single function to populate the listboxes as well as run the items to make it even more efficient.
Questions & Comments are welcome.