//################################################## //config_paths_startup //################################################## void config_paths_startup() { const char *bbinterfacedotrc = "BBInterface.rc"; const char *bbinterfacerc = "BBInterfacerc"; config_path_plugin = new char[MAX_PATH]; config_path_mainscript = new char[MAX_PATH]; //Create a temporary string char *temp = new char[MAX_PATH]; //Get the name of this file GetModuleFileName(plugin_instance_plugin, temp, MAX_PATH); //Find the last slash char *lastslash = strrchr(temp, '\\'); if (lastslash) lastslash[1] = '\0'; //Copy the path of the plugin strcpy(config_path_plugin, temp); //Find the plugin .rc file bool found = false; //Try the plugin directory, "BBInterface.rc" strcpy(config_path_mainscript, config_path_plugin); strcat(config_path_mainscript, bbinterfacedotrc); if (FileExists(config_path_mainscript)) found = true; //If not found, try the plugin directory, "BBInterfacerc" if (!found) { strcpy(config_path_mainscript, config_path_plugin); strcat(config_path_mainscript, bbinterfacerc); if (FileExists(config_path_mainscript)) found = true; } //If not found, try the Blackbox directory, "BBInterface.rc" if (!found) { GetBlackboxPath(config_path_mainscript, MAX_PATH); strcat(config_path_mainscript, bbinterfacedotrc); if (FileExists(config_path_mainscript)) found = true; } //If not found, try the Blackbox directory, "BBInterfacerc" if (!found) { GetBlackboxPath(config_path_mainscript, MAX_PATH); strcat(config_path_mainscript, bbinterfacerc); if (FileExists(config_path_mainscript)) found = true; } //All hope is lost if (!found) { strcpy(config_path_mainscript, config_path_plugin); strcat(config_path_mainscript, bbinterfacedotrc); } //Delete the temporary string delete temp; }
char *make_bb_path(char *dest, const char *src) { dest[0]=0; if (is_relative_path(src)) GetBlackboxPath(dest, MAX_PATH); return strcat(dest, src); }
char *replace_shellfolders(char *buffer, const char *path, bool search_path) { char temp [MAX_PATH]; const char *p = unquote(temp, path); if (false == is_relative_path(temp)) return strcpy(buffer, temp); int id = get_csidl(&p); if (CSIDL_BLACKBOX == id || CSIDL_CURTHEME == id) { GetBlackboxPath(buffer, MAX_PATH); buffer[strlen(buffer)-1] = 0; } else if (NO_CSIDL == id) { if (search_path) { if (SearchPath(NULL, temp, ".exe", MAX_PATH, buffer, NULL)) return buffer; else return strcpy(buffer, temp); } GetBlackboxPath(buffer, MAX_PATH); } else { // special folders, like CONTROLS LPITEMIDLIST pID; HRESULT hr = SHGetSpecialFolderLocation(NULL, id, &pID); if (NOERROR != hr) return strcpy(buffer, temp); // returns also things like "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}" // (unlike SHGetPathFromIDList) BOOL result = sh_get_displayname(NULL, pID, SHGDN_FORPARSING, buffer); SHMalloc_Free(pID); if (FALSE == result) return strcpy(buffer, temp); } if (p) strcat(buffer, p); return buffer; }
const char *get_relative_path(const char *p) { char home[MAX_PATH]; GetBlackboxPath(home, MAX_PATH); int n = strlen(home); if (0 == memicmp(p, home, n)) return p + n; return p; }
LPITEMIDLIST get_folder_pidl (const char *rawpath) { if (NULL==rawpath) return NULL; char path [MAX_PATH]; char temp [MAX_PATH]; unquote(temp, rawpath); if (false == is_relative_path(temp)) { if (is_alpha(temp[0]) && temp[1] == ':' && temp[2] == 0) temp[2] = '\\', temp[3] = 0; return sh_getpidl(NULL, temp); } const char *p = temp; int id = get_csidl(&p); if (NO_CSIDL == id || CSIDL_BLACKBOX == id || CSIDL_CURTHEME == id) { GetBlackboxPath(path, MAX_PATH); if (NO_CSIDL != id) path[strlen(path)-1] = 0; if (p) strcat(path, p); return sh_getpidl(NULL, path); } // special folders, like CONTROLS LPITEMIDLIST pID1, pID; if (NOERROR != SHGetSpecialFolderLocation(NULL, id, &pID1)) return sh_getpidl(NULL, temp); if (NULL == p) { pID = duplicateIDlist(pID1); } else { pID = NULL; // a subdirectory is specified, like APPDATA\microsoft // so get its local pidl and append it IShellFolder* pThisFolder = sh_get_folder_interface(pID1); if (pThisFolder) { LPITEMIDLIST pID2 = sh_getpidl(pThisFolder, p+1); if (pID2) { pID = joinIDlists(pID1, pID2); m_free(pID2); } } } SHMalloc_Free(pID1); return pID; }
void ReadRCSettings() { char temp[MAX_LINE_LENGTH], path[MAX_LINE_LENGTH], defaultpath[MAX_LINE_LENGTH]; int nLen; // First we look for the config file in the same folder as the plugin... GetModuleFileName(hInstance, rcpath, sizeof(rcpath)); nLen = strlen(rcpath) - 1; while (nLen >0 && rcpath[nLen] != '\\') nLen--; rcpath[nLen + 1] = 0; strcpy(temp, rcpath); strcpy(path, rcpath); strcat(temp, "bbseekbar.rc"); strcat(path, "bbseekbarrc"); // ...checking the two possible filenames bbseekbar.rc and bbseekbarrc ... if (FileExists(temp)) strcpy(rcpath, temp); else if (FileExists(path)) strcpy(rcpath, path); // ...if not found, we try the Blackbox directory... else { // ...but first we save the default path (bbseekbar.rc in the same // folder as the plugin) just in case we need it later (see below)... strcpy(defaultpath, temp); GetBlackboxPath(rcpath, sizeof(rcpath)); strcpy(temp, rcpath); strcpy(path, rcpath); strcat(temp, "bbseekbar.rc"); strcat(path, "bbseekbarrc"); if (FileExists(temp)) strcpy(rcpath, temp); else if (FileExists(path)) strcpy(rcpath, path); else // If no config file was found, we use the default path and settings, and return { strcpy(rcpath, defaultpath); xpos = ypos = 10; width = 160; height = 20; alpha = 160; styleType = 1; trackStyleType = 5; knobStyleType = 1; appearance = 0; playerType = 0; alwaysOnTop = false; transparency = false; snapWindow = true; pluginToggle = false; inSlit = false; showBorder = true; allowtip = true; vertical = false; reversed = false; WriteRCSettings(); //write a file for editing later return; } } // If a config file was found we read the plugin settings from the file... xpos = ReadInt(rcpath, "bbseekbar.x:", 10); ypos = ReadInt(rcpath, "bbseekbar.y:", 10); if (xpos >= GetSystemMetrics(SM_CXVIRTUALSCREEN)) xpos = 10; if (ypos >= GetSystemMetrics(SM_CYVIRTUALSCREEN)) ypos = 10; width = ReadInt(rcpath, "bbseekbar.width:", 160); height = ReadInt(rcpath, "bbseekbar.height:", 20); alpha = ReadInt(rcpath, "bbseekbar.alpha:", 160); styleType = ReadInt(rcpath, "bbseekbar.styleType:", 1); trackStyleType = ReadInt(rcpath, "bbseekbar.trackStyleType:", 5); knobStyleType = ReadInt(rcpath, "bbseekbar.knobStyleType:", 1); appearance = ReadInt(rcpath, "bbseekbar.appearance:", 0); playerType = ReadInt(rcpath, "bbseekbar.playerType:", 0); alwaysOnTop = ReadBool(rcpath, "bbseekbar.alwaysontop:", false); transparency = ReadBool(rcpath, "bbseekbar.transparency:", false); snapWindow = ReadBool(rcpath, "bbseekbar.snapwindow:", true); pluginToggle = ReadBool(rcpath, "bbseekbar.pluginToggle:", false); inSlit = ReadBool(rcpath, "bbseekbar.inSlit:", false); showBorder = ReadBool(rcpath, "bbseekbar.showBorder:", true); allowtip = ReadBool(rcpath, "bbseekbar.allowtooltip:", true); vertical = ReadBool(rcpath, "bbseekbar.vertical:", false); reversed = ReadBool(rcpath, "bbseekbar.reversed:", false); }
void ReadRCSettings() { char temp[MAX_LINE_LENGTH], path[MAX_LINE_LENGTH], defaultpath[MAX_LINE_LENGTH]; int nLen; // First we look for the config file in the same folder as the plugin... GetModuleFileName(hInstance, rcpath, sizeof(rcpath)); nLen = strlen(rcpath) - 1; while (nLen >0 && rcpath[nLen] != '\\') nLen--; rcpath[nLen + 1] = 0; strcpy(temp, rcpath); strcpy(path, rcpath); strcat(temp, "bbnoter.rc"); strcat(path, "bbnoterrc"); // ...checking the two possible filenames bbanalog.rc and bbanalogrc ... if (FileExists(temp)) strcpy(rcpath, temp); else if (FileExists(path)) strcpy(rcpath, path); // ...if not found, we try the Blackbox directory... else { // ...but first we save the default path (bbanalog.rc in the same // folder as the plugin) just in case we need it later (see below)... strcpy(defaultpath, temp); GetBlackboxPath(rcpath, sizeof(rcpath)); strcpy(temp, rcpath); strcpy(path, rcpath); strcat(temp, "bbnoter.rc"); strcat(path, "bbnoterrc"); if (FileExists(temp)) strcpy(rcpath, temp); else if (FileExists(path)) strcpy(rcpath, path); else // If no config file was found, we use the default path and settings, and return { strcpy(rcpath, defaultpath); xpos = ypos = 10; width = 100; height = 70; alpha = 160; wantInSlit = true; alwaysOnTop = true; snapWindow = true; transparency = false; fullTrans = false; drawBorder = false; pluginToggle = false; fontSize = 6; strcpy(windowStyle, "windowlabel"); strcpy(bitmapFile, ".none"); noBitmap = true; ratio = 1; WriteRCSettings(); return; } } // If a config file was found we read the plugin settings from the file... //Always checking non-bool values to make sure they are the right format xpos = ReadInt(rcpath, "bbnoter.x:", 10); ypos = ReadInt(rcpath, "bbnoter.y:", 10); width = ReadInt(rcpath, "bbnoter.width:", 100); height = ReadInt(rcpath, "bbnoter.height:", 50); ratio = ReadInt(rcpath, "bbnoter.ratio:", 1); if (ratio<=0) ratio = 1; alpha = ReadInt(rcpath, "bbnoter.alpha:", 160); if(alpha > 255) alpha = 255; if(ReadString(rcpath, "bbnoter.inSlit:", NULL) == NULL) wantInSlit = true; else wantInSlit = ReadBool(rcpath, "bbnoter.inSlit:", true); alwaysOnTop = ReadBool(rcpath, "bbnoter.alwaysOnTop:", true); drawBorder = ReadBool(rcpath, "bbnoter.drawBorder:", true); snapWindow = ReadBool(rcpath, "bbnoter.snapWindow:", true); transparency = ReadBool(rcpath, "bbnoter.transparency:", false); fullTrans = ReadBool(rcpath, "bbnoter.fullTrans:", false); fontSize = ReadInt(rcpath, "bbnoter.fontSize:", 6); alwaysOnTop = ReadBool(rcpath, "bbnoter.alwaysontop:", true); pluginToggle = ReadBool(rcpath, "bbnoter.pluginToggle:", false); strcpy(windowStyle, ReadString(rcpath, "bbnoter.windowStyle:", "windowlabel")); if(((StrStrI(windowStyle, "label") == NULL) || ((StrStrI(windowStyle, "label") != NULL) && (strlen(windowStyle) > 5))) && (StrStrI(windowStyle, "windowlabel") == NULL) && (StrStrI(windowStyle, "clock") == NULL) && (StrStrI(windowStyle, "button") == NULL) && (StrStrI(windowStyle, "buttonpr") == NULL) && (StrStrI(windowStyle, "toolbar") == NULL)) strcpy(windowStyle, "windowLabel"); strcpy(bitmapFile, ReadString(rcpath, "bbnoter.bitmapFile:", ".none")); if (strcmp(bitmapFile,".none")==0) noBitmap = true; else noBitmap = false; }