- Visual C++源码
- Visual Basic源码
- C++ Builder源码
- Java源码
- Delphi源码
- C/C++源码
- PHP源码
- Perl源码
- Python源码
- Asm源码
- Pascal源码
- Borland C++源码
- Others源码
- SQL源码
- VBScript源码
- JavaScript源码
- ASP/ASPX源码
- C#源码
- Flash/ActionScript源码
- matlab源码
- PowerBuilder源码
- LabView源码
- Flex源码
- MathCAD源码
- VBA源码
- IDL源码
- Lisp/Scheme源码
- VHDL源码
- Objective-C源码
- Fortran源码
- tcl/tk源码
- QT源码
SkinList.cpp
资源名称:VC++视频传输.rar [点击查看]
上传用户:hxb_1234
上传日期:2010-03-30
资源大小:8328k
文件大小:4k
源码类别:
VC书籍
开发平台:
Visual C++
- /**************************************************************************************
- * *
- * *
- **************************************************************************************/
- #include "SkinList.h"
- #include <windows.h>
- #include <string.h>
- #include <stdlib.h>
- /*
- * 外壳信息类
- */
- SkinInfo::SkinInfo(char *directory) {
- this->directory = (char *) new char[strlen(directory)+1];
- this->directory = strcpy(this->directory, directory);
- this->directory[strlen(directory)] = '';
- this->name = strrchr(this->directory, '\') + 1;
- if(name == NULL) {
- name = directory;
- }
- }
- SkinInfo::~SkinInfo() {
- free(this->directory);
- }
- /*
- * 外壳链表类
- */
- SkinList::SkinList() {
- this->totalSkins = 0;
- this->skins = NULL;
- this->skinsDir = NULL;
- /*
- * 从注册表中得到链表路径
- */
- HKEY key;
- DWORD created, size, type;
- LONG result;
- /*
- * 打开注册键
- */
- result = RegCreateKeyEx(HKEY_CURRENT_USER, "Software\DivXNetworks\ThePlaya",
- 0, "CONFIG", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS,
- NULL, &key, &created);
- if(result != ERROR_SUCCESS) {
- MessageBox(NULL, "Couldn't load skins directories", "", MB_OK);
- return;
- }
- switch(created) {
- case REG_CREATED_NEW_KEY:
- /*
- * 第一次启动(缺省)
- *
- */
- this->skinsDir = NULL;
- break;
- case REG_OPENED_EXISTING_KEY:
- /*
- * 读值
- */
- this->skinsDir = (char *) new char[MAX_PATH];
- size = MAX_PATH;
- result = RegQueryValueEx(key, "SkinsDir", 0, &type, (BYTE *)this->skinsDir, &size);
- if(result == ERROR_MORE_DATA) {
- this->skinsDir = (char *) realloc(this->skinsDir, size);
- result = RegQueryValueEx(key, "SkinsDir", 0, &type, (BYTE *)this->skinsDir, &size);
- }
- if(result != ERROR_SUCCESS) {
- free(this->skinsDir);
- this->skinsDir = NULL;
- }
- break;
- default:
- break;
- }
- RegCloseKey(key);
- }
- SkinList::~SkinList() {
- free(this->skinsDir);
- }
- void SkinList::Add(SkinInfo *skinInfo) {
- skinlist_t *node;
- node = (skinlist_t *) new skinlist_t;
- node->info = skinInfo;
- node->next = this->skins;
- this->skins = node;
- this->totalSkins++;
- }
- int SkinList::SetDir(char *dir) {
- this->skinsDir = dir;
- HKEY key;
- DWORD created;
- LONG result;
- /*
- * 尝试打开注册键
- */
- result = RegCreateKeyEx(HKEY_CURRENT_USER, "Software\DivXNetworks\ThePlaya",
- 0, "CONFIG", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS,
- NULL, &key, &created);
- if(result != ERROR_SUCCESS) {
- MessageBox(NULL, "Couldn't save skins dir", "", MB_OK);
- return 0;
- }
- RegSetValueEx(key, "SkinsDir", 0, REG_SZ, (BYTE *) this->skinsDir, strlen(this->skinsDir));
- return 1;
- }
- int SkinList::Scan() {
- this->totalSkins = 0;
- this->skins = NULL;
- if(this->skinsDir != NULL && strcmp(this->skinsDir, "Default") != 0) {
- WIN32_FIND_DATA dirData;
- HANDLE hFind = NULL, hSkin = NULL;
- char *str;
- str = (char *) new char[(strlen(this->skinsDir))];
- strcpy(str, this->skinsDir);
- hFind = FindFirstFile(strcat(str, "\*.*"), &dirData);
- if(hFind != NULL) {
- if(strcmp(dirData.cFileName, ".") != 0 && strcmp(dirData.cFileName, "..") != 0) {
- if(dirData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
- this->Add(new SkinInfo(dirData.cFileName));
- }
- }
- while(FindNextFile(hFind, &dirData)) {
- if(strcmp(dirData.cFileName, ".") != 0 && strcmp(dirData.cFileName, "..") != 0) {
- if(dirData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
- char filename[MAX_PATH];
- strcpy(filename, this->skinsDir);
- strcat(strcat(filename, "\"), dirData.cFileName);
- this->Add(new SkinInfo(filename));
- }
- }
- }
- FindClose(hFind);
- }
- }
- return 0;
- }
- int Reset() {
- return 0;
- }
- int SkinList::getNumberOfSkins() {
- return this->totalSkins;
- }
- SkinInfo *SkinList::getSkinInfo(int position) {
- if(position >= 0 && position < this->totalSkins) {
- int i;
- skinlist_t *node;
- node = this->skins;
- for(i = 0; i < position; i++) {
- node = node->next;
- }
- return node->info;
- }
- return NULL;
- }