⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 getfilename.cpp

📁 一个播放器 使用了evc 大家可以参考下 哦
💻 CPP
📖 第 1 页 / 共 2 页
字号:
 /***************************************************************************************
 *This program is free software; you can redistribute it and/or modify					*
 * it under the terms of the GNU General Public License as published by					*
 * the Free Software Foundation; either version 2 of the License, or					*
 * (at your option) any later version.													*
 *																						*
 * The GPL can be found at: http://www.gnu.org/copyleft/gpl.html						*
 *																						*
 *																						*	
 ****************************************************************************************
 * Authors:																			  *
 *          Marc Dukette                                                              *
 **************************************************************************************/

#include "stdafx.h"
#include "GetFileName.h"
#include "resource.h"
#include <commctrl.h>
#include <wininet.h>
#ifdef SMART
#include <aygshell.h>
#include <sipapi.h>
	#define SHCMBM_GETMENU      (WM_USER + 402)
	#define SHGetMenu( hWndMB )  ( HMENU )SendMessage( ( hWndMB ), SHCMBM_GETMENU, ( WPARAM )0, ( LPARAM )0 )
	#define CommandBar_GetMenu( hWndMB, x )		( HMENU )SendMessage( ( hWndMB ), SHCMBM_GETMENU, ( WPARAM )0, ( LPARAM )0 )
	typedef BOOL (CALLBACK* paygshell_SHCreateMenuBar)( SHMENUBARINFO *pmb );
	paygshell_SHCreateMenuBar aygshell_SHCreateMenuBar;
#endif

HANDLE hmod;
unsigned int vkCtrl;
typedef struct _entry{
	TCHAR Name[200];
	TCHAR Type[20];
	int	  Size;
	TCHAR URL[200];
}entry;

BOOL APIENTRY DllMain( HANDLE hModule, 
                       DWORD  ul_reason_for_call, 
                       LPVOID lpReserved
					 )
{
	hmod=hModule;
    switch (ul_reason_for_call)
	{
		case DLL_PROCESS_ATTACH:
		case DLL_THREAD_ATTACH:
		case DLL_THREAD_DETACH:
		case DLL_PROCESS_DETACH:
			break;
    }
    return TRUE;
}
TCHAR CurrentPath[200]=_T("\\");
//TCHAR PreviousPath[200]=_T("\\");
TCHAR FileName[200]=_T("");
TCHAR g_Filter[200];

HWND g_Parent;
 char data[100000];
 TCHAR up[100000];
 TCHAR dataw[100000];
 TCHAR History[100][200];
 int HistoryPos=0;
int SortCol=1;
int Dir=1;
int g_webView=0;
TCHAR MultiBuff[100000];
// Global Variables:
bool AllowMulti=false;
bool bEnd;
HINSTANCE			hInst;			// The current instance
HWND				hwndCB;			// The command bar handle
HWND hwndList;
// Forward declarations of functions included in this code module:
ATOM				MyRegisterClass	(HINSTANCE, LPTSTR);
BOOL				InitInstance	(HINSTANCE, int);
LRESULT CALLBACK	WndProc			(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK	About			(HWND, UINT, WPARAM, LPARAM);
int SelectedRow=-1;
HWND hwndMain;
HWND hwndURL;
HWND hwndBrowse;
HWND hwndOK;
HWND hwndFolder;

int NumFiles=0;
long oldproc;
bool KeyDown=false;
LRESULT CALLBACK ListProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);

int CALLBACK ListViewCompareProc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
{
	entry *pHouse1 = (entry *)lParam1;
	entry *pHouse2 = (entry *)lParam2;
	LPTSTR lpStr1, lpStr2;
	int iResult;
	
	if (pHouse1 && pHouse2)
	{
		switch( lParamSort)
		{
		case 0:     // sort by Address
			lpStr1 = pHouse1->Name;
			lpStr2 = pHouse2->Name;
			if (!wcscmp(pHouse1->Type,_T(""))) return -1*Dir;
			if (!wcscmp(pHouse2->Type,_T(""))) return 1*Dir;
			if (!wcscmp(pHouse1->Type,_T("Dir"))&&(wcscmp(pHouse2->Type,_T("Dir")))) return -1*Dir;
			if (!wcscmp(pHouse2->Type,_T("Dir"))&&(wcscmp(pHouse1->Type,_T("Dir")))) return 1*Dir;
			iResult = wcsicmp(lpStr1, lpStr2);
			break;
			
		case 1:     // sort by city

			lpStr1 = pHouse1->Type;
			lpStr2 = pHouse2->Type;
			if (!wcscmp(pHouse1->Type,_T(""))) return -1*Dir;
			if (!wcscmp(pHouse2->Type,_T(""))) return 1*Dir;
			if (!wcscmp(pHouse1->Type,_T("Dir"))&&(wcscmp(pHouse2->Type,_T("Dir")))) return -1*Dir;
			if (!wcscmp(pHouse2->Type,_T("Dir"))&&(wcscmp(pHouse1->Type,_T("Dir")))) return 1*Dir;
			iResult = wcsicmp(lpStr1, lpStr2);
			break;
			
		case 2:     // sort by price
			if (!g_webView)
				iResult = pHouse1->Size - pHouse2->Size;
			else
			{
				lpStr1 = pHouse1->URL;
				lpStr2 = pHouse2->URL;
				if (!wcscmp(pHouse1->Type,_T(""))) return -1*Dir;
				if (!wcscmp(pHouse2->Type,_T(""))) return 1*Dir;
				if (!wcscmp(pHouse1->Type,_T("Dir"))&&(wcscmp(pHouse2->Type,_T("Dir")))) return -1*Dir;
				if (!wcscmp(pHouse2->Type,_T("Dir"))&&(wcscmp(pHouse1->Type,_T("Dir")))) return 1*Dir;
				iResult = wcsicmp(lpStr1, lpStr2);
			}
			break;
			
		default:
			iResult = 0;
			break;
			
		}
		
	}
	return(iResult*Dir);
}


ATOM MyRegisterClass(HINSTANCE hInstance, LPTSTR szWindowClass)
{
	WNDCLASS	wc;

    wc.style			= CS_HREDRAW | CS_VREDRAW;
    wc.lpfnWndProc		= (WNDPROC) WndProc;
    wc.cbClsExtra		= 0;
    wc.cbWndExtra		= 0;
    wc.hInstance		= hInstance;
    wc.hIcon			= NULL; //LoadIcon(hInstance, MAKEINTRESOURCE(IDI_OPENFILE));
    wc.hCursor			= 0;
    wc.hbrBackground	= (HBRUSH) GetStockObject(GRAY_BRUSH);
    wc.lpszMenuName		= 0;
    wc.lpszClassName	= szWindowClass;

	return RegisterClass(&wc);
}

void GetFileExt(LPTSTR File,LPTSTR EXT)
{
     LPTSTR temp=File;
     int dcnt=0;
	int done=0;
	int found=0;
	int n=wcslen(File);
	while (!done&&(n>=0))
	{
		if (File[n]==L'.')
		{
			found=1;
			done=1;
			continue;
		}
		if (File[n]==L'/')
		{
			done=1;
			continue;
		}
		n--;
	}
	if (found&&(n>0))
	{
		wcscpy(EXT,File+n+1);
	}
	else
	{
		wcscpy(EXT,_T(""));
	}

}
void GetBaseURL(LPTSTR URL,LPTSTR base)
{
	int n=wcslen(URL);
	int done=0;
	int found=0;

	while (!done&&(n>=0))
	{
		if (URL[n]==L'.')
			found=1;
		if (URL[n]==L'/')
		{
			done=1;
			continue;
		}
		n--;
	}
	if (found&&(n>6))
	{
		wcsncpy(base,URL,n);
		base[n]=0;
	}
	else
	{
		wcscpy(base,URL);
	}
}
void ParseURL(HWND hWnd, LPTSTR URL)
{
     TCHAR temp[500];
	TCHAR baseURL[200];
     TCHAR * next=up;
     unsigned long n;
	int tot=0;
     HINTERNET hSess=InternetOpen(_T("HTTPList"),INTERNET_OPEN_TYPE_DIRECT,NULL,NULL,NULL);
	 if (!hSess)
	 {
			MessageBox(hwndList,_T("Could not open an Internet connection"),_T(""),MB_OK);
			return;
	 }
     HINTERNET hFile=InternetOpenUrl(hSess,URL,NULL,NULL,INTERNET_FLAG_DONT_CACHE,NULL);
	 if (!hFile)
	 {
			MessageBox(hwndList,_T("Could not open URL"),_T(""),MB_OK);
			return;
	 }
	 GetBaseURL(URL,baseURL);
	wcscpy(History[HistoryPos],URL);
	if (HistoryPos<99) HistoryPos++;

	LVITEM lv;
	for (n=0;n<ListView_GetItemCount(hwndList);n++)
	{
		lv.iItem=n;
		lv.mask=LVIF_PARAM;
		ListView_GetItem(hwndList,&lv);
		if (lv.lParam) delete (entry*)lv.lParam;
	}	

	
	int lastDir=0; 
	lv.mask=LVIF_TEXT|LVIF_IMAGE|LVIF_PARAM ;
	lv.pszText=_T("");
	lv.cchTextMax=1;
	lv.iSubItem=0;
	ListView_DeleteAllItems(hWnd);
 			lv.iImage=1;

			
			entry* e=new entry;
			lv.lParam=(LPARAM)e;
			wcscpy(e->Name,_T(".."));
			wcscpy(e->Type,_T(""));
		lv.iItem=lastDir;
		ListView_InsertItem(hWnd,&lv);
		ListView_SetItemText(hWnd,lastDir,0,_T(".."));
			lastDir++;
			
		do{
			n=0;
			InternetReadFile(hFile,(void*)(data+tot),100000-tot,&n);
			tot+=n;
		}while(n&&(tot<100000));
		InternetCloseHandle(hSess);
		InternetCloseHandle(hFile);
  	 MultiByteToWideChar(CP_ACP, 0, data, tot, dataw, tot);
     wcscpy(up,dataw);
     wcsupr(up);
     while((next=wcsstr(next,_T("<A ")))!=0)
     {
          TCHAR* end;
          TCHAR one[500];
		  TCHAR name[100];
		  TCHAR fname[100];
		  next=wcsstr(next,_T("HREF="));
		  if (!next) break;
          next+=5;

          if (wcsstr(next,_T("\""))==next)
          {
               next++;
               end=wcsstr(next,_T("\""));
          }
          else if (wcsstr(next,_T("\'"))==next)
          {
               next++;
               end=wcsstr(next,_T("\'"));
          }
          else
          {
               end=wcsstr(next,_T(">"));
          }
		  if (!end) continue;
		  while(*(end-1)==_T(' ')||(*(end-1)==_T('\r'))||(*(end-1)==_T('\n'))||(*(end-1)==_T('\t')))
		  {
			   end--;
		   }
          //*end=0;
          *(dataw+(end-up))=0;
          wcscpy(one,_T(""));
          if (!wcsstr(dataw+(next-up),_T("://")))
          {
			  if (*(dataw+(next-up))!=L'/')
			   {
	               wcscpy(one,baseURL);
				   if (baseURL[wcslen(baseURL)-1]!=L'/') wcscat(one,_T("/"));
			   }
			   else
			   {
				   TCHAR* root=baseURL+8;
				   root=wcsstr(root,_T("/"));
				   if (!root)
				   {
					   wcscpy(one,baseURL);
				   }
				   else
				   {
						wcsncpy(one,baseURL,root-baseURL);
						one[root-baseURL]=0;
				   }
			   }
          }
          wcscat(one,dataw+(next-up));
		
		  
		TCHAR* nstart=one;
		TCHAR* nend=one;

		while ((nstart=wcsstr(nstart,_T("/")))!=NULL)
		{
			nstart++;
			nend=nstart;
		}
		wcscpy(fname,nend);
		  
		wcscpy(temp,one);
		nstart=wcsstr(next,_T(">"));
		nstart++;
		nend=wcsstr(nstart,_T("<"));
		wcsncpy(name,nstart,(nend-nstart));
		name[(nend-nstart)]=0;
		
		
		
		TCHAR ext[100]; 
		if (!wcscmp(name,_T(""))) wcscpy(name,dataw+(next-up));
         GetFileExt(one,ext);
		  wcsupr(ext);
          if (!wcscmp(ext,_T(""))||(wcsstr(_T("ASP,HTM,HTML,PHP"),ext)))
			{

			lv.iImage=1;
			lv.iItem=lastDir;
			entry* e=new entry;
			lv.lParam=(LPARAM)e;
			wcscpy(e->Name,name);
			wcscpy(e->URL,one);
			wcscpy(e->Type,_T("Dir"));
			ListView_InsertItem(hWnd,&lv);
			ListView_SetItemText(hWnd,lastDir,0,name);
			ListView_SetItemText(hWnd,lastDir,1,_T("Dir"));
			ListView_SetItemText(hWnd,lastDir,2,one);
					
		
			lastDir++;
		  }
          if (wcscmp(ext,_T(""))&&(wcsstr(g_Filter,ext)))
		  {
				lv.iItem=lastDir;
				entry* e=new entry;
				lv.lParam=(LPARAM)e;
				wcscpy(e->Name,fname);
				wcscpy(e->URL,one);
				wcscpy(e->Type,ext);
				if (!wcscmp(ext,_T("PDL")))
					lv.iImage=2;
				else if (!wcscmp(ext,_T("MP3")))
					lv.iImage=3;				
				else if (!wcscmp(ext,_T("OGG")))
					lv.iImage=3;				
				else
					lv.iImage=0;
				ListView_InsertItem(hWnd,&lv);
				ListView_SetItemText(hWnd,lastDir,0,fname);
	
				ListView_SetItemText(hWnd,lastDir,1,ext);
				ListView_SetItemText(hWnd,lastDir,2,one);
		  }
     }
  ListView_SortItems( hWnd,
		ListViewCompareProc,
		(LPARAM) SortCol);

}


void FillWindow(HWND hWnd, LPTSTR Path)
{
  WIN32_FIND_DATA FileData;   // Data structure describes the file found
  HANDLE hSearch;             // Search handle returned by FindFirstFile
  BOOL bFinished = FALSE;
 	int lastDir=0; 
	LVITEM lv;

	for (int n=0;n<ListView_GetItemCount(hwndList);n++)
	{
		lv.iItem=n;
		lv.mask=LVIF_PARAM;
		ListView_GetItem(hwndList,&lv);
		if (lv.lParam) delete (entry*)lv.lParam;
	}	
	
	lv.mask=LVIF_TEXT|LVIF_IMAGE|LVIF_PARAM ;
	lv.pszText=_T("");
	lv.cchTextMax=1;
	lv.iSubItem=0;
	ListView_DeleteAllItems(hWnd);
 			lv.iImage=1;
			entry* e=new entry;
			lv.lParam=(LPARAM)e;
			wcscpy(e->Name,_T(".."));
			wcscpy(e->Type,_T(""));
		lv.iItem=lastDir;
		ListView_InsertItem(hWnd,&lv);
		ListView_SetItemText(hWnd,lastDir,0,_T(".."));
		lastDir++;
 hSearch = FindFirstFile (Path, &FileData);
  if (hSearch == INVALID_HANDLE_VALUE)
  {
    return;
  }

 while (!bFinished)
  {

	TCHAR temp[100];
		if (FileData.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY)
	  {

			lv.iImage=1;
			lv.iItem=lastDir;
			entry* e=new entry;
			lv.lParam=(LPARAM)e;
			wcscpy(e->Name,FileData.cFileName);
			e->Size=0;
			wcscpy(e->Type,_T("Dir"));
			ListView_InsertItem(hWnd,&lv);
			ListView_SetItemText(hWnd,lastDir,0,FileData.cFileName);
			ListView_SetItemText(hWnd,lastDir,1,_T("Dir"));
		
		
		lastDir++;
	  }
		wcscpy(temp,FileData.cFileName);
//		LPTSTR ext=wcstok(temp,_T("."));
//	  ext=wcstok(NULL,_T("."));
		TCHAR ext[100]; 
         GetFileExt(temp,ext);
		  wcsupr(ext);
		if (wcscmp(ext,_T("")))
		{
		  wcsupr(ext);
		  if (wcsstr(g_Filter,ext))
		  {
				lv.iItem=lastDir;
				entry* e=new entry;
				lv.lParam=(LPARAM)e;
				wcscpy(e->Name,FileData.cFileName);
				e->Size=FileData.nFileSizeLow;
				wcscpy(e->Type,ext);
				if (!wcscmp(ext,_T("PDL")))
				{
					lv.iImage=2;
				}
				else if (!wcscmp(ext,_T("MP3")))
				{
					lv.iImage=3;
				}
				else if (!wcscmp(ext,_T("OGG")))
				{
					lv.iImage=3;
				}
				else
				{
					lv.iImage=0;
				}
				ListView_InsertItem(hWnd,&lv);
				ListView_SetItemText(hWnd,lastDir,0,FileData.cFileName);
	
				ListView_SetItemText(hWnd,lastDir,1,ext);
				_itow(FileData.nFileSizeLow/1000,temp,10);
				wcscat(temp,_T("kb"));
				ListView_SetItemText(hWnd,lastDir,2,temp);
		  }
		}

    if (!FindNextFile (hSearch, &FileData))
    {
      bFinished = TRUE;
    }
	ListView_SetItemState(hwndList,0,LVIS_SELECTED|LVIS_FOCUSED,0xFFFF);
 }

  // Close the search handle.

  FindClose (hSearch);
  ListView_SortItems( hWnd,
		ListViewCompareProc,
		(LPARAM) SortCol);

}


#define REG_BASE			L"software\\PocketMVP"
#define OPT_URL			L"URLs"



void FillRecent()
{
	HKEY hKey = 0;
	DWORD dwSize = 0;
	DWORD dwType = 0;
	DWORD dwTmp;
	TCHAR temp[10];
	TCHAR value[200];
	int n=0;
	if ( ERROR_SUCCESS == RegOpenKeyEx( HKEY_LOCAL_MACHINE, REG_BASE, 0, 0, &hKey ) )
	{

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -