示例#1
0
INT CALLBACK LoggingPage::dialogProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam)
{
	switch ( msg )
	{
		case WM_COMMAND:
		{
			if ( HIWORD(wParam)==EN_CHANGE )
			{
				if ( IsWindowVisible(hWnd) ) {
					SendMessage(GetParent(hWnd),UWM_SETTINGS_CHANGED,NULL,NULL);
				}
			}

			switch ( wParam )
			{
				case IDC_BUTTON_BROWSE:
				{
					char path[MAX_PATH] = {0};

					BROWSEINFO bi = {0};
					bi.hwndOwner = hWnd;
					
					LPITEMIDLIST pidl = SHBrowseForFolder(&bi);
					if ( pidl!=NULL ) {
						SHGetPathFromIDList(pidl,path);
						SetWindowText(m_hEditPath,path);
					}

					IMalloc *pMalloc = NULL;
					if ( SUCCEEDED(SHGetMalloc(&pMalloc)) ) {
						pMalloc->Free(pidl);
						pMalloc->Release();
					}
				}
				break;
			}
		}
		break;
	}

	return 0;
}
示例#2
0
int get_appdata_folder(char *path,int size)
{
	int found=FALSE;
	ITEMIDLIST *pidl;
	IMalloc	*palloc;
	HWND hwindow=0;
	if(path==0 || size<MAX_PATH)
		return found;
	if(SHGetSpecialFolderLocation(hwindow,CSIDL_APPDATA,&pidl)==NOERROR){
		if(SHGetPathFromIDList(pidl,path)){
			_snprintf(path,size,"%s\\%s",path,APP_NAME);
			found=TRUE;
		}
		if(SHGetMalloc(&palloc)==NOERROR){
			palloc->Free(pidl);
			palloc->Release();
		}
	}
	return found;
}
示例#3
0
LRESULT OptionsWindow::onCommand(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	int wmId, wmEvent;
	wmId = LOWORD(wParam);
	wmEvent = HIWORD(wParam);
	BROWSEINFO bi = { 0 };
	bi.lpszTitle = _T("Browse for folder");
	LPITEMIDLIST pidl;

	// Parse the menu selections:
	switch (wmId) {
		case IDM_OK:
			saveOptions();
			PostMessage(_parent->getHandle(), UWM_CLOSE_OPTIONS, 0, 0);
			break;
		case IDM_CANCEL:
			PostMessage(_parent->getHandle(), UWM_CLOSE_OPTIONS, 0, 0);
			break;
		case IDM_APLLY:
			saveOptions();
			break;
		case IDM_BROWSE:
			pidl = SHBrowseForFolder(&bi);
			if (pidl != 0) {
				TCHAR path[MAX_PATH];
				if (SHGetPathFromIDList(pidl, path)) {
					_savePathEditBox->setWindowText(path);
				}

				IMalloc *imalloc = 0;
				if (SUCCEEDED(SHGetMalloc(&imalloc))) {
					imalloc->Free(pidl);
					imalloc->Release();
				}
			}
			break;
		default:
			return DefWindowProc(hWnd, message, wParam, lParam);
	}
	return 0;
}
示例#4
0
BOOL	CPathlib::SelectFolder( HWND hWnd, LPCSTR lpszTitle, LPSTR lpszFolder )
{
	BROWSEINFO	bi;
	LPITEMIDLIST	pidl;

	ZeroMemory( &bi, sizeof(bi) );
	bi.hwndOwner = hWnd;
	bi.lpszTitle = lpszTitle;
	bi.ulFlags = BIF_RETURNONLYFSDIRS;
	// For Folder setup
	bi.lpfn = (BFFCALLBACK)BffCallback;

	// 最後に'\'が付いているとデフォルト選択してくれない(Win98)ので...
	if( lpszFolder ) {
		if( ::strlen(lpszFolder) > 3 ) {
			if( lpszFolder[::strlen(lpszFolder)-1] == '\\' )
				lpszFolder[::strlen(lpszFolder)-1] = NULL;
		}
		bi.lParam = (LPARAM)lpszFolder;
	} else {
		bi.lParam = NULL;
	}

	string	path;
	if( (pidl = ::SHBrowseForFolder( &bi )) ) {
		path.resize( _MAX_PATH+1 );
		::SHGetPathFromIDList( pidl, lpszFolder );
		if( ::strlen(lpszFolder) > 3 ) {	// ドライブ名の場合を除く
			::strcat( lpszFolder, "\\" );
		}
		IMalloc* pMalloc;
		::SHGetMalloc( &pMalloc );
		if( pMalloc ) {
			pMalloc->Free( pidl );
			pMalloc->Release();
		}
		return	TRUE;
	}

	return	FALSE;
}
示例#5
0
/** Finds the location of the "special" Windows folder using the given CSIDL
 * value. If the folder cannot be found, the given default path is used. */
QString
win32_get_folder_location(int /*folder*/, QString defaultPath)
{
#if 0
    TCHAR path[MAX_PATH+1];
    LPITEMIDLIST idl;
    IMalloc *m;
    HRESULT result;

    /* Find the location of %PROGRAMFILES% */
    if (SUCCEEDED(SHGetSpecialFolderLocation(NULL, folder, &idl))) {
        /* Get the path from the IDL */
        result = SHGetPathFromIDList(idl, path);
        SHGetMalloc(&m);
        if (m) {
            m->Release();
        }
        if (SUCCEEDED(result)) {
            QT_WA(return QString::fromUtf16((const ushort *)path); ,
                  return QString::fromLocal8Bit((char *)path);)
        }
示例#6
0
int GetIconIndexForCSIDL(int csidl)
{
    LPITEMIDLIST pidl = 0;
    SHGetSpecialFolderLocation(NULL, csidl, &pidl);
    if (pidl)
    {
        SHFILEINFO shellInfo;
        SHGetFileInfo(LPCTSTR(pidl), FILE_ATTRIBUTE_NORMAL,
                      &shellInfo, sizeof(shellInfo),
                      SHGFI_PIDL | SHGFI_SYSICONINDEX);
        IMalloc  *pMalloc;
        SHGetMalloc(&pMalloc);
        if (pMalloc)
        {
            pMalloc->Free(pidl);
            pMalloc->Release();
        }
        return shellInfo.iIcon;
    }
    return 0;
}
示例#7
0
文件: folder.cpp 项目: Execsl/usnap
int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
 	// TODO: Place code here.

	CoInitialize(NULL); 

	TCHAR	pdn[MAX_PATH];		// display name
	TCHAR	folder[MAX_PATH];	// path name

	BROWSEINFO bi; 
	LPITEMIDLIST	pidl; 

	bi.hwndOwner		= NULL; 
	bi.pidlRoot		= NULL; 
	bi.pszDisplayName	= pdn; 
	bi.lpszTitle		= "select a directory: "; 
	bi.ulFlags		= BIF_EDITBOX; //BIF_USENEWUI; 
	bi.lpfn			= 0; 
	bi.lParam		= 0; 
	bi.iImage		= 0; 

	pidl	= SHBrowseForFolder(&bi); 

	if (pidl) {
		SHGetPathFromIDList(pidl, folder); 

		IMalloc	*pMalloc = NULL; 
		if (SUCCEEDED(SHGetMalloc(&pMalloc))) {
			pMalloc->Free(pidl); 
			pMalloc->Release(); 
		}
	}

	CoUninitialize(); 

	return pidl != NULL;
}
/**
 *	@brief	Returns the path of folder in which user settings is stored.
 *	@return user settings folder path.
 */
const Path& WinCoveredCalcApp::getUserSettingsPath()
{
	if (userSettingsPath.IsEmpty())
	{
		Path path;
		
		// Application Data の下
		ITEMIDLIST* pIdList;
		HRESULT hResult = ::SHGetSpecialFolderLocation(NULL, CSIDL_APPDATA, &pIdList);
		if(S_OK == hResult)
		{
			// 得られた ITEMIDLIST からフォルダ名を取得
			TCHAR pathString[MAX_PATH];
			if (::SHGetPathFromIDList(pIdList, pathString))
			{
				path.Assign(pathString);
			}
			
			// システムが確保した ITEMIDLIST を解放
			IMalloc* pMalloc;
			::SHGetMalloc(&pMalloc);
			if (NULL != pMalloc)
			{
				pMalloc->Free(pIdList);
				pMalloc->Release();
			}
		}
		if (!path.IsEmpty())
		{
			userSettingsPath = path.Append(ALITERAL("Hironytic")).Append(ALITERAL("CoveredCalc"));
		}
		else
		{
			// Application Data が得られなかったら、アプリケーションのあるフォルダに保存
			userSettingsPath = getAppFolderPath();
		}
	}
	return userSettingsPath;
}
HRESULT C$$Safe_root$$PropPage::GetPageInfo( LPPROPPAGEINFO pPageInfo )
{
	IMalloc* pIMalloc;
	if (FAILED( CoGetMalloc( MEMCTX_TASK, &pIMalloc ) ))
		return E_FAIL;

	pPageInfo->pszTitle = (LPOLESTR)pIMalloc->Alloc( 256 );

	pIMalloc->Release();

	if (!pPageInfo->pszTitle)
		return E_OUTOFMEMORY;

	static const char szTitle[] = "$$Safe_root$$";
	mbstowcs( pPageInfo->pszTitle, szTitle, strlen( szTitle ) );

	// Populate the page info structure
	pPageInfo->cb					= sizeof(PROPPAGEINFO);
	pPageInfo->size.cx      = 100;
	pPageInfo->size.cy      = 100;
	pPageInfo->pszDocString = NULL;
	pPageInfo->pszHelpFile  = NULL;
	pPageInfo->dwHelpContext= 0;

	// Create the property page in order to determine its size
	HWND const hWnd = CreateDialogParam( theApp.m_hInstance, MAKEINTRESOURCE( IDD_PROPPAGE ), 
													 ::GetDesktopWindow(), DialogProc, 0 );
	if (hWnd)
	{
		// Get the dialog size and destroy the window
		RECT rc;
		::GetWindowRect( hWnd, &rc );
		pPageInfo->size.cx = rc.right - rc.left;
		pPageInfo->size.cy = rc.bottom - rc.top;
		::DestroyWindow( hWnd );
	}

	return S_OK;
}
示例#10
0
        virtual void run()
        {
            QString result;

            QWidget *topParent = windowManager().realParentWindow(mParent ? mParent : windowManager().mainWindowShown());
            QString title = mCaption.isNull() ? tr ("Select a directory") : mCaption;

            TCHAR path [MAX_PATH];
            path [0] = 0;
            TCHAR initPath [MAX_PATH];
            initPath [0] = 0;

            BROWSEINFO bi;
            bi.hwndOwner = topParent ? topParent->winId() : 0;
            bi.pidlRoot = 0;
            bi.lpszTitle = (TCHAR*)(title.isNull() ? 0 : title.utf16());
            bi.pszDisplayName = initPath;
            bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_STATUSTEXT | BIF_NEWDIALOGSTYLE;
            bi.lpfn = winGetExistDirCallbackProc;
            bi.lParam = uintptr_t(&mDir);

            LPITEMIDLIST itemIdList = SHBrowseForFolder (&bi);
            if (itemIdList)
            {
                SHGetPathFromIDList (itemIdList, path);
                IMalloc *pMalloc;
                if (SHGetMalloc (&pMalloc) != NOERROR)
                    result = QString::null;
                else
                {
                    pMalloc->Free (itemIdList);
                    pMalloc->Release();
                    result = QString::fromUtf16 ((ushort*)path);
                }
            }
            else
                result = QString::null;
            QApplication::postEvent (mTarget, new GetExistDirectoryEvent (result));
        }
示例#11
0
// ---
HRESULT CCodeGen::ExtractString( UINT id, BYTE** output ) {
	
	if ( !output ) 
		return E_INVALIDARG;
	
	static char buff[1000];
	HINSTANCE inst = _Module.GetModuleInstance();
	int len = ::LoadString( inst, id, buff, sizeof(buff) ) + 1;
	
	if ( len ) {
		IMalloc* alloc = 0;
		HRESULT hr = ::CoGetMalloc( 1, &alloc );
		if ( SUCCEEDED(hr) ) {
			*output = (BYTE*)alloc->Alloc( len );
			::memcpy( *output, buff, len );
			alloc->Release();
		}
		return hr;
	}
	else
		return HRESULT_FROM_WIN32( ::GetLastError() );
}
示例#12
0
文件: main.cpp 项目: bamandel/CSR
int main()
{

    TCHAR path[MAX_PATH];
	BROWSEINFO bi = { 0 };
	bi.lpszTitle = ("Locate folder containing patient data.");
	LPITEMIDLIST pidl = SHBrowseForFolder ( &bi );

	if ( pidl != 0 )
	{
		// get the name of the folder and put it in path
		SHGetPathFromIDList ( pidl, path );

		//Set the current directory to path
		SetCurrentDirectory ( path );
                string name(path);


		// free memory used
		IMalloc * imalloc = 0;
		if ( SUCCEEDED( SHGetMalloc ( &imalloc )) )
		{
			imalloc->Free ( pidl );
			imalloc->Release ( );
		}
		replace(name.begin(),name.end(),'\\','/');
                CandidateSearch search(name);
	}


 //CandidateSearch search ("Josh");
        cout<<"Please type 'e' when ready to exit"<<endl;
        string input = "";
        getline(cin,input);
        if(input == "e")
            return 0;
    return (0);
}
示例#13
0
BOOL SelectFolder(HWND hWnd,WCHAR *ach)
{
	BOOL    bResult = FALSE;
    IMalloc *pm;
    BROWSEINFO bi;
    LPITEMIDLIST pidl;

    if (!FAILED(CoInitialize(NULL)))
	{
		bi.hwndOwner      = hWnd;
		bi.pidlRoot       = NULL;
		bi.pszDisplayName = ach;
		bi.lpszTitle      = NULL;
		bi.ulFlags        = BIF_RETURNONLYFSDIRS;
		bi.lpfn           = NULL;
		bi.lParam         = 0;
		bi.iImage         = 0;

		pidl = SHBrowseForFolder(&bi);

		if (pidl)
		{
			SHGetPathFromIDList(pidl, ach);

			// TrimRightChar(ach,'\\',MAX_PATH);

			SHGetMalloc(&pm);
			if (pm)
			{
				 pm->Free(pidl);
				 pm->Release();
			}
			bResult = TRUE;
		}
		CoUninitialize();
	}
	return bResult;
}
示例#14
0
文件: XenUtils.cpp 项目: wolqws/sws
bool BrowseForDirectory(const char *text, const char *initialdir, char *fn, int fnsize)
{
  wchar_t widename[4096];
  wchar_t widetext[4096];
  MultiByteToWideChar(CP_UTF8, 0, initialdir, -1, widename, 4096);
  MultiByteToWideChar(CP_UTF8, 0, text, -1, widetext, 4096);

  // explicitly call unicode versions and then convert filename back to utf8
  BROWSEINFOW bi={g_hwndParent, NULL, widename, widetext, BIF_RETURNONLYFSDIRS | BIF_NEWDIALOGSTYLE, BrowseForDirectoryCallbackProc, (LPARAM)widename};
  LPITEMIDLIST idlist = SHBrowseForFolderW( &bi );
  if (idlist) 
  {
    SHGetPathFromIDListW( idlist, widename);

    IMalloc *m;
    SHGetMalloc(&m);
    m->Free(idlist);
    
    WideCharToMultiByte(CP_UTF8, 0, widename, -1, fn, fnsize, NULL, NULL);
    return true;
  }
  return false;
}
示例#15
0
INT_PTR FileInfViewDlgShow(HINSTANCE hInst, HWND hwndOwner, CFilesInf* pFilesInf)
{
	 HRSRC r = FindResource(hInst, MAKEINTRESOURCE(IDD_DLG_FILES_INF), RT_DIALOG);
	 HGLOBAL g = LoadResource(hInst, r);

	 IMalloc *pIMalloc;
	 HRESULT hr = SHGetMalloc(&pIMalloc);
	 if (FAILED(hr))
		 return 0;

	 FilesInfDlgData* dlgData = (FilesInfDlgData*) pIMalloc->Alloc(sizeof(FilesInfDlgData));
	 dlgData->filesInf = pFilesInf;

   INT_PTR ret = DialogBoxIndirectParam(hInst, 
       (LPDLGTEMPLATE)LockResource(g), 
       hwndOwner, 
       (DLGPROC)FileInfViewDlgProc,
			 (LPARAM)dlgData); 

   pIMalloc->Free(dlgData);
	 pIMalloc->Release();
    return ret; 
}
示例#16
0
//*********************************************************
// 関数SHGetSpecialFolderPath() が使用できない環境で特殊フォルダのパスを取得する。
// 引数は SHGetSpecialFolderPath() と同じ。
//*********************************************************
static BOOL GetSpecialFolderPath( HWND hWnd, int nFolder, char *Path )
{
	IMalloc    *pMalloc;
	ITEMIDLIST *pidl;

	Path[0] = 0;

	if ( NOERROR == SHGetMalloc( &pMalloc ) )
	{
		if ( NOERROR == SHGetSpecialFolderLocation( hWnd, nFolder, &pidl ) )
		{
			if ( SHGetPathFromIDList( pidl, Path ) )
			{
				pMalloc->Free( pidl );
				pMalloc->Release();
				return TRUE;
			}
			pMalloc->Free( pidl );
		}
		pMalloc->Release();
	}
	return FALSE;
}//GetSpecialFolder
示例#17
0
    bool OpenSelectFolderDialog (HWND hwndOwner, LPCWSTR lpszTitle, wstring& wstrPath)
    {
        bool fRet = false;
        HRESULT hr = 0;
        BROWSEINFO bi = {0};
        WCHAR szPath[MAX_PATH + 1] = {0};
        LPITEMIDLIST pidl = NULL;
        IMalloc * pIMalloc = NULL;

        bi.hwndOwner = hwndOwner;
        bi.lpszTitle = lpszTitle;

        pidl = SHBrowseForFolder(&bi);
        if (pidl == NULL)
            goto END;

        fRet = SHGetPathFromIDList(pidl, szPath);
        if (!fRet)
            goto END;    

        wstrPath = szPath;

        hr = SHGetMalloc(&pIMalloc);
        if (FAILED (hr))
            goto END;

        fRet = true;
    END:
        if (pIMalloc)
        {    
            pIMalloc->Free(pidl);
            pidl = NULL;
            pIMalloc->Release();
        }

        return fRet;
    }
示例#18
0
void DirectoryChooser::OnBnClickedAddDirectory()
{
	shared_ptr<Options> ops = ((CLaunchyDlg*)AfxGetMainWnd())->options;

	// TODO: Add your control notification handler code here
	BROWSEINFO bi = { 0 };
	bi.lpszTitle = _T("Pick a Directory");
	bi.hwndOwner = GetSafeHwnd();
	LPITEMIDLIST pidl = SHBrowseForFolder ( &bi );

	vector<DirOptions> D = ops->get_Directories();

	if ( pidl != 0 )
	{
		// get the name of the folder
		TCHAR path[MAX_PATH];
		if ( SHGetPathFromIDList ( pidl, path ) )
		{
			// ( "Selected Folder: %s\n", path );
			DirOptions d;
			d.dir = path;
			D.push_back(d);
			Directories.AddString(path);
		}

		// free memory used
		IMalloc * imalloc = 0;
		if ( SUCCEEDED( SHGetMalloc ( &imalloc )) )
		{
			imalloc->Free ( pidl );
			imalloc->Release ( );
		}
	}

	ops->set_Directories(D);
	SetWidthByContentInListBox(this, IDC_LIST1);
}
示例#19
0
void OpenDirWithNewFolderAbility()
{
	BROWSEINFO bi;
	wchar_t Buffer[MAX_PATH];
	bi.hwndOwner = NULL;
	bi.pidlRoot = NULL;
	bi.pszDisplayName = Buffer;
	bi.lpszTitle = L"选择目标文件路劲";
	bi.ulFlags = BIF_EDITBOX | BIF_NEWDIALOGSTYLE;
	bi.lParam = 0;
	bi.lpfn = BrowseCallbackProc;

	LPITEMIDLIST pIDList = SHBrowseForFolder(&bi);
	if (pIDList) {
		SHGetPathFromIDList(pIDList, Buffer);

		IMalloc* imalloc = 0;
		if (SUCCEEDED(SHGetMalloc(&imalloc)))
		{
			imalloc->Free(pIDList);
			imalloc->Release();
		}
	}
}
示例#20
0
文件: setup.cpp 项目: byplayer/yamy
	// WM_COMMAND
	BOOL wmCommand(int /* notify_code */, int i_id, HWND /* hwnd_control */) {
		switch (i_id) {
		case IDC_BUTTON_browse: {
			_TCHAR folder[GANA_MAX_PATH];

			BROWSEINFO bi;
			ZeroMemory(&bi, sizeof(bi));
			bi.hwndOwner      = m_hwnd;
			bi.pidlRoot       = NULL;
			bi.pszDisplayName = folder;
			bi.lpszTitle      = g_resource->loadString(IDS_selectDir);
			ITEMIDLIST *browse = SHBrowseForFolder(&bi);
			if (browse != NULL) {
				if (SHGetPathFromIDList(browse, folder)) {
					if (createDirectories(folder))
						Edit_SetText(GetDlgItem(m_hwnd, IDC_EDIT_path), folder);
				}
				IMalloc *imalloc = NULL;
				if (SHGetMalloc(&imalloc) == NOERROR)
					imalloc->Free((void *)browse);
			}
			return TRUE;
		}

		case IDOK: {
			_TCHAR buf[GANA_MAX_PATH];
			Edit_GetText(GetDlgItem(m_hwnd, IDC_EDIT_path), buf, NUMBER_OF(buf));
			if (buf[0]) {
				g_destDir = normalizePath(buf);
				m_doRegisterToStartMenu =
					(IsDlgButtonChecked(m_hwnd, IDC_CHECK_registerStartMenu) ==
					 BST_CHECKED);
				m_doRegisterToStartUp =
					(IsDlgButtonChecked(m_hwnd, IDC_CHECK_registerStartUp) ==
					 BST_CHECKED);

				int curSel =
					ComboBox_GetCurSel(GetDlgItem(m_hwnd, IDC_COMBO_keyboard));
				g_flags = SetupFile::Normal;
#if 0
				if (checkOs(SetupFile::W2k))
#endif
				{
					switch (curSel) {
					case 0:
						g_keyboardKind = KEYBOARD_KIND_109;
						g_flags = Flag_Usb;
						break;
					case 1:
						g_keyboardKind = KEYBOARD_KIND_104;
						g_flags = Flag_Usb;
						break;
#if 0
					case 2:
						g_keyboardKind = KEYBOARD_KIND_109;
						break;
					case 3:
						g_keyboardKind = KEYBOARD_KIND_104;
						break;
#endif
					};
				}
#if 0
				else {
					switch (curSel) {
					case 0:
						g_keyboardKind = KEYBOARD_KIND_109;
						break;
					case 1:
						g_keyboardKind = KEYBOARD_KIND_104;
						break;
					};
				}
#endif

#if 0
				if (g_flags == Flag_Usb)
					if (message(IDS_usbWarning, MB_OKCANCEL | MB_ICONWARNING, m_hwnd)
							== IDCANCEL)
						return TRUE;
#endif

				if (createDirectories(g_destDir.c_str()))
					EndDialog(m_hwnd, install());
				else
					message(IDS_invalidDirectory, MB_OK | MB_ICONSTOP, m_hwnd);
			} else
				message(IDS_mayuEmpty, MB_OK, m_hwnd);
			return TRUE;
		}

		case IDCANCEL: {
			CHECK_TRUE( EndDialog(m_hwnd, 0) );
			return TRUE;
		}
		}
		return FALSE;
	}
示例#21
0
BOOL CFileTreeCtrl::OnNotify ( WPARAM wParam, LPARAM lParam, LRESULT* pResult )
{
	LPNMHDR pnmh = (LPNMHDR) lParam;
	// Tree ?
	if (wParam == 0)
	{
		switch (pnmh->code)
		{
		case TVN_GETDISPINFO:
			{
				  LPNMTVDISPINFO lpdi = (LPNMTVDISPINFO)pnmh;
				  CTreeItemInfo* pItemInfo = (CTreeItemInfo*)lpdi->item.lParam;
				  SHFILEINFO     sfi;
				  if (pItemInfo)
				  {
					  if(lpdi->item.mask & TVIF_TEXT)
						 {
						 if(SHGetFileInfo((LPCTSTR)pItemInfo->pidlFullyQual, 0, &sfi, sizeof(sfi), SHGFI_PIDL | SHGFI_DISPLAYNAME))
							lstrcpy(lpdi->item.pszText, sfi.szDisplayName);
						 }
					  
					  if(lpdi->item.mask & TVIF_IMAGE)
						 {
						 if(SHGetFileInfo((LPCTSTR)pItemInfo->pidlFullyQual, 0, &sfi, sizeof(sfi), SHGFI_PIDL | SHGFI_SYSICONINDEX | SHGFI_SMALLICON | SHGFI_LINKOVERLAY))
							lpdi->item.iImage = sfi.iIcon;
						 }
					  if(lpdi->item.mask & TVIF_SELECTEDIMAGE)
						 {
						 if(SHGetFileInfo((LPCTSTR)pItemInfo->pidlFullyQual, 0, &sfi, sizeof(sfi), SHGFI_PIDL | SHGFI_SYSICONINDEX | SHGFI_SMALLICON | SHGFI_OPENICON))
							lpdi->item.iSelectedImage = sfi.iIcon;
						 }
				  }
			}
			break;
		case TVN_ITEMEXPANDING:
			{
				LPNMTREEVIEW   pnmtv = (LPNMTREEVIEW)pnmh;
				IShellFolder *pParentFolder;

				if(pnmtv->action == TVE_COLLAPSE)
					_TreeCtrl.Expand(pnmtv->itemNew.hItem, TVE_COLLAPSE | TVE_COLLAPSERESET);
				else if(pnmtv->action == TVE_EXPAND)
				{
					HCURSOR	 hCursor;
					TVITEM   tvItem = {0};
					tvItem.mask = TVIF_PARAM;
					tvItem.hItem = pnmtv->itemNew.hItem;
					if(!_TreeCtrl.GetItem(&tvItem))
						return FALSE;
					CTreeItemInfo* pItemInfo = (CTreeItemInfo*)tvItem.lParam;
					hCursor = SetCursor(LoadCursor(NULL, IDC_WAIT));
					
					if(pItemInfo->pParentFolder == 0)
					{
						if(FAILED(SHGetDesktopFolder(&pParentFolder)))
							return FALSE;
						if (_RootDirectory != "")
						{
							SHGetDesktopFolder(&pParentFolder);
							if(FAILED(pParentFolder->BindToObject(pItemInfo->pidlSelf, NULL, IID_IShellFolder, (void**)&pParentFolder)))
								return 0;
						}
					}
					else if(FAILED(pItemInfo->pParentFolder->BindToObject(pItemInfo->pidlSelf, NULL, IID_IShellFolder, (void**)&pParentFolder)))
						return 0;
				
					_TreeCtrl.SetRedraw(FALSE);
					enumObjects (pnmtv->itemNew.hItem, pParentFolder, pItemInfo->pidlFullyQual);

					_TreeCtrl.SetRedraw(TRUE);
					pParentFolder->Release();
					SetCursor(hCursor);
				}		
			}
			break;
		case TVN_DELETEITEM:
			{
				LPNMTREEVIEW   pnmtv = (LPNMTREEVIEW)pnmh;
				IMalloc* pMalloc;
				CTreeItemInfo* pItemInfo = (CTreeItemInfo*)pnmtv->itemOld.lParam;
				if (pItemInfo)
				{
					if (SUCCEEDED(SHGetMalloc(&pMalloc)))
					{
						if (pItemInfo->dwFlags == 0)
						{
							pMalloc->Free(pItemInfo->pidlSelf);
							pMalloc->Release();
							if (pItemInfo->pParentFolder)
							{
								pItemInfo->pParentFolder->Release();
								pMalloc->Free(pItemInfo->pidlFullyQual);
							}
						}
					}
					delete pItemInfo;
				}
			}
			break;
		case NM_RCLICK:
			{
				TVHITTESTINFO  tvhti;
				GetCursorPos(&tvhti.pt);
				::ScreenToClient(_TreeCtrl, &tvhti.pt);
				tvhti.flags = LVHT_NOWHERE;
				TreeView_HitTest(_TreeCtrl, &tvhti);

				if(TVHT_ONITEM & tvhti.flags)
				{
					::ClientToScreen(_TreeCtrl, &tvhti.pt);
					doItemMenu(_TreeCtrl, tvhti.hItem , &tvhti.pt);
				}
			}
			break;
		case NM_DBLCLK:
			{
				// Get the item
				TVHITTESTINFO  tvhti;
				GetCursorPos(&tvhti.pt);
				::ScreenToClient(_TreeCtrl, &tvhti.pt);
				tvhti.flags = LVHT_NOWHERE;
				TreeView_HitTest(_TreeCtrl, &tvhti);

				if(TVHT_ONITEM & tvhti.flags)
				{
					if (_TreeCtrl.GetRootItem () != tvhti.hItem)
					{
						::ClientToScreen(_TreeCtrl, &tvhti.pt);
						doClick(_TreeCtrl, tvhti.hItem);
					}
				}
			}
			break;
		}
	}
	return CWnd::OnNotify ( wParam, lParam, pResult );
}
示例#22
0
///////////////////////////////////////////////////////////////////////////////
//
// XBrowseForFolder()
//
// Purpose:     Invoke the SHBrowseForFolder API.  If lpszInitialFolder is
//              supplied, it will be the folder initially selected in the tree 
//              folder list.  Otherwise, the initial folder will be set to the 
//              current directory.  The selected folder will be returned in 
//              lpszBuf.
//
// Parameters:  hWnd              - handle to the owner window for the dialog
//              lpszInitialFolder - initial folder in tree;  if NULL, the initial
//                                  folder will be the current directory.
//              lpszBuf           - buffer for the returned folder path
//              dwBufSize         - size of lpszBuf in TCHARs
//
// Returns:     BOOL - TRUE = success;  FALSE = user hit Cancel
//
BOOL XBrowseForFolder(HWND hWnd,
					  LPCTSTR lpszInitialFolder,
					  LPTSTR lpszBuf,
					  DWORD dwBufSize)
{
	_ASSERTE(lpszBuf);
	_ASSERTE(dwBufSize >= MAX_PATH);

	if (lpszBuf == NULL || dwBufSize < MAX_PATH)
		return FALSE;

	lpszBuf[0] = _T('\0');

	TCHAR szInitialPath[MAX_PATH*2];
	ZeroMemory(szInitialPath, sizeof(szInitialPath));

	if (lpszInitialFolder && lpszInitialFolder[0] != _T('\0'))
	{
		_tcsncpy(szInitialPath, lpszInitialFolder, 
					sizeof(szInitialPath)/sizeof(TCHAR)-2);
	}
	else
	{
		// no initial folder, set to current directory
		::GetCurrentDirectory(sizeof(szInitialPath)/sizeof(TCHAR)-2, 
				szInitialPath);
	}

	BROWSEINFO bi;
	ZeroMemory(&bi, sizeof(BROWSEINFO));

	bi.hwndOwner = hWnd;
	bi.ulFlags   = BIF_RETURNONLYFSDIRS;	// do NOT use BIF_NEWDIALOGSTYLE, 
											// BIF_EDITBOX, or BIF_STATUSTEXT
	bi.lpfn      = BrowseCallbackProc;
	bi.lParam    = (LPARAM) szInitialPath;

	LPITEMIDLIST pidl = SHBrowseForFolder(&bi);

	BOOL bRet = FALSE;

	if (pidl)
	{
		TCHAR szBuffer[MAX_PATH*2];
		szBuffer[0] = _T('\0');

		if (SHGetPathFromIDList(pidl, szBuffer))
		{
			ZeroMemory(lpszBuf, dwBufSize);
			_tcsncpy(lpszBuf, szBuffer, dwBufSize-1);
			bRet = TRUE;
		}
		else
		{
//			TRACE(_T("SHGetPathFromIDList failed\n"));
		}

		IMalloc *pMalloc = NULL; 
		if (SUCCEEDED(SHGetMalloc(&pMalloc)) && pMalloc) 
		{  
			pMalloc->Free(pidl);  
			pMalloc->Release(); 
		}
	}

	return bRet;
}
示例#23
0
void CSAORI::exec(const CSAORIInput& in,CSAORIOutput& out)
{
	out.result_code = SAORIRESULT_BAD_REQUEST;

	if ( in.args.size() < 0 ) { return; }

	if ( wcsicmp(in.args[0].c_str(),L"hwnd") == 0 ) {
		if ( in.args.size() >= 2 ) {
			g_hWnd = reinterpret_cast<HWND>(wcstoul(in.args[1].c_str(),NULL,10));
			out.result_code = SAORIRESULT_OK;
		}
		return;
	}
	else if ( wcsicmp(in.args[0].c_str(),L"get") == 0 ) {
		out.result_code = SAORIRESULT_INTERNAL_SERVER_ERROR;

		//検索対象と検索結果
		string_t find_string;
		if ( in.args.size() >= 2 ) {
			find_string = in.args[1];
			if ( wcsnicmp(find_string.c_str(),L"system:",7) == 0 ) {
				int nFolder = CSIDL_PERSONAL;
				const char_t *str = find_string.c_str()+7;
				if ( wcsicmp(str,L"bitbucket") == 0 || wcsicmp(str,L"trash") == 0 ) {
					nFolder = CSIDL_BITBUCKET;
				}
				else if ( wcsicmp(str,L"internet") == 0 ) {
					nFolder = CSIDL_INTERNET;
				}
				else if ( wcsicmp(str,L"drives") == 0 || wcsicmp(str,L"computer") == 0 || wcsicmp(str,L"mycomputer") == 0 ) {
					nFolder = CSIDL_DRIVES;
				}

				LPITEMIDLIST pidl;

				IMalloc *pMalloc;
				::SHGetMalloc( &pMalloc );
				::SHGetSpecialFolderLocation(NULL,nFolder,&pidl);

				SHFILEINFOA fileinfo;
				::SHGetFileInfoA(reinterpret_cast<char*>(pidl),0,&fileinfo,sizeof(fileinfo),SHGFI_PIDL|SHGFI_DISPLAYNAME);

				pMalloc->Free(pidl);
				pMalloc->Release();

				find_string = SAORI_FUNC::MultiByteToUnicode(fileinfo.szDisplayName);
			}
		}

		WindowIconInfo *pFound = NULL;

		std::vector<WindowIconInfo> vec;

		OSVERSIONINFO osvi;
		ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
		osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
		::GetVersionEx( &osvi );

		unsigned int count;
		if ( osvi.dwMajorVersion >= 6 ) {
			count = GetDesktopIconInfoListW5(vec,out);
		}
		/*else if ( osvi.dwMajorVersion >= 5 ) {
			if ( osvi.dwMinorVersion >= 1 ) {
				count = GetDesktopIconInfoListW5(vec,out);
			}
			else {
				count = GetDesktopIconInfoListW4(vec,out);
			}
		}*/
		else {
			count = GetDesktopIconInfoListW4(vec,out);
		}

		for ( unsigned int i = 0 ; i < count ; ++i ) {
			string_t item = vec[i].m_name;

			if ( ! pFound ) {
				if ( wcsstr(vec[i].m_name.c_str(),find_string.c_str()) ) {
					pFound = &(vec[i]);
				}
			}

			char_t rect_text[128];
			swprintf(rect_text,L"\1%d,%d",vec[i].m_pt.x,vec[i].m_pt.y);
			item += rect_text;

			out.values.push_back(item);
		}

		out.result_code = SAORIRESULT_OK;

		if ( pFound ) {
			char_t rect_text[128];

			swprintf(rect_text,L"%d\1",pFound->m_index);
			out.result = rect_text;

			out.result += pFound->m_name;

			swprintf(rect_text,L"\1%d,%d",pFound->m_pt.x,pFound->m_pt.y);
			out.result += rect_text;
		}
		else {
			out.result = L"";
		}
	}
	else if ( wcsicmp(in.args[0].c_str(),L"empty_trash") == 0 ) {
		_beginthread(EmptyTrashThread,0,NULL);
		out.result_code = SAORIRESULT_OK;
	}
	else if ( wcsicmp(in.args[0].c_str(),L"query_trash") == 0 ) {
		DWORD totalSize = 0;
		DWORD totalItems = 0;

		QueryTrash(totalSize,totalItems);

		char_t size_text[32];
		char_t item_text[32];
		swprintf(size_text,L"%u",totalSize);
		swprintf(item_text,L"%u",totalItems);

		out.result = item_text;
		out.values.push_back(item_text);
		out.values.push_back(size_text);

		out.result_code = SAORIRESULT_OK;
	}
}
示例#24
0
static BOOL GetPidlAndShellFolder (char* pszPath, IShellFolder** ppsfOut, LPITEMIDLIST* ppidlOut)
{
	IShellFolder * pd = NULL;
	IMalloc* shMalloc = NULL;
	LPITEMIDLIST pidlFull = NULL;
	ULONG cch;
	ULONG attrs;
	BOOL success = FALSE;

	if (!SUCCEEDED (SHGetDesktopFolder (&pd)))
		goto BailOut;

	if (!SUCCEEDED (SHGetMalloc (&shMalloc)))
		goto BailOut;

	WCHAR wpath[MAX_PATH];
	mbstowcs (wpath, pszPath, 1+lstrlen(pszPath));

	//get fully-qualified pidl
	if (!SUCCEEDED (pd->ParseDisplayName (NULL, NULL, wpath, &cch, &pidlFull, &attrs)))
		goto BailOut;
	
	IShellFolder *psfCurr, *psfNext;
	if (!SUCCEEDED (pd->QueryInterface (IID_IShellFolder, (LPVOID*)&psfCurr)))
		goto BailOut;

	//for each pidl component, bind to folder
	LPITEMIDLIST pidlNext, pidlLast;
	pidlNext = PidlNext (pidlFull);
	pidlLast = pidlFull;
	
	while (pidlNext->mkid.cb != 0)
	{
		
		UINT uSave = pidlNext->mkid.cb;		//stop the chain temporarily
		pidlNext->mkid.cb = 0;				//so we can bind to the next folder 1 deeper
		if (!SUCCEEDED (psfCurr->BindToObject(pidlLast, NULL, IID_IShellFolder, (LPVOID*)&psfNext)))
			goto BailOut;
		pidlNext->mkid.cb = uSave;			//restore the chain

		psfCurr->Release();					//and set up to work with the next-level folder
		psfCurr = psfNext;
		pidlLast = pidlNext;

		pidlNext = PidlNext (pidlNext);		//advance to next pidl
	}

	success = TRUE;

	*ppidlOut = CopyPidl (pidlLast, shMalloc);
	*ppsfOut = psfCurr;

BailOut:
	//cleanup
	if (pidlFull != NULL && shMalloc != NULL)
		shMalloc->Free (pidlFull);		//other pidl's were only offsets into this, and don't need freeing
	if (pd != NULL)
		pd->Release();
	if (shMalloc != NULL)
		shMalloc->Release();

	return success;
}
示例#25
0
void CDBManageTrueDlg::OnBnClickedButtonOpendatapackageTrue()
{
	// TODO: 在此添加控件通知处理程序代码
	BROWSEINFO bi;
	char Buffer[MAX_PATH];
	//CString m_DatasetFoldPath ;//将路径保存在一个CString对象里
	bi.hwndOwner = this->m_hWnd;
	bi.pidlRoot =NULL;//初始化制定的root目录很不容易
	bi.pszDisplayName =(LPWSTR)Buffer;//此参数如为NULL则不能显示对话框
	bi.lpszTitle = L"选择光谱数据集文件夹路径";
	bi.ulFlags =BIF_USENEWUI ; //BIF_EDITBOX;//带编辑框的风格
	bi.lpfn = NULL;
	bi.lParam = 0;
	bi.iImage=IDR_MAINFRAME;
	//初始化入口参数bi结束
	LPITEMIDLIST pIDList = SHBrowseForFolder(&bi);//调用显示选择对话框

	if(pIDList==NULL)
	{	
		return;
	}
	SHGetPathFromIDList(pIDList,(LPWSTR)Buffer);
	//取得文件夹路径到Buffer里
	m_SpecDataFoldPath.Format(L"%s",Buffer);
	// free memory used      
	IMalloc * imalloc = 0;
	if (SUCCEEDED(SHGetMalloc(&imalloc)))
	{
		imalloc->Free (pIDList);
		imalloc->Release();
	}
	//从文件夹中导入光谱数据及相关信息
	CString strDir=m_SpecDataFoldPath;
	strDir.Replace(L"\\",L"\\\\");
	strDir += "\\*.*";

	// 遍历得到所有子文件夹名
	CFileFind finder; 
	BOOL bWorking = finder.FindFile(strDir);

	/*m_ary_PicturesPath.RemoveAll();
	m_ary_SpecFileName.RemoveAll();
	m_ary_SpecFilePath.RemoveAll();
	m_ListSpectrumToAdd.DeleteAllItems();
	//m_ary_ProjectPathNew.RemoveAll();*/
	while (bWorking)  
	{
		bWorking = finder.FindNextFile();
		CString str=finder.GetFileName();
		if(str.Right(4)==L".CSV"||str.Right(4)==L".csv" &&L"." !=str &&L".." != str)//注意该句需要排除“.”“..”
		{
			CString filename;
			CString fileTitle;
			//CString str=finder.GetFileName();
			m_ary_SpecFilePath.Add(finder.GetFilePath());
			//获取文件名(不包含后缀)  
			//采用CString的Left(int count)截取CString中从左往右数的count个字符  
			//fileName.GetLength()-4中的4表示".csv"四个字符  
			m_ary_SpecFileName.Add(finder.GetFileTitle());//将文件名(不包含后缀)添加到数组中  
		}
		if(str.Right(4)==L".jpg" ||str.Right(4)==L".bmp"||str.Right(4)==L".gif"&&L"." !=str &&L".." != str)m_ary_PicturesPath.Add(finder.GetFilePath());
		if(str==L"数据说明.xls"||str==L"数据说明.xlsx"&&L"." !=str &&L".." != str)m_ExcelInfoPath=finder.GetFilePath();
	}
	finder.Close();
	if(m_ary_SpecFileName.GetCount()==0)
	{
		MessageBox(L"该文件夹中没有规定格式的光谱数据,请重新选择!",L"警告",MB_ICONWARNING);
		return;
	}
	if(m_ary_SpecFileName.GetCount()<30)
	{
		MessageBox(L"光谱数量太少",L"警告",MB_ICONWARNING);
	}
	m_PicIndex=0;
	CString Winename;
	CString Wineinfo=L"";
	CString Comfrom;
	CString ReceiveDate;
	CString Wineinfotemp;
	if(m_ExcelInfoPath.IsEmpty())
	{
		if(IDOK==MessageBox(L"数据包中缺少必要的光谱说明文件,是否自行填写?",L"信息缺失",MB_OKCANCEL|MB_ICONQUESTION))
		{
			CInputSpecDatasetInfoDlg InputSpecDatasetInfoDlg;
			if(IDOK==InputSpecDatasetInfoDlg.DoModal())
			{
				m_WineName=InputSpecDatasetInfoDlg.m_WineName;
				m_AlcoholContent=InputSpecDatasetInfoDlg.m_AlcoholContent;
				Wineinfo=m_AlcoholContent+L"度,";
				m_Flavour=InputSpecDatasetInfoDlg.m_Flavour;
				Wineinfo+=m_Flavour;
				Wineinfo+=L",";
				m_Brand=InputSpecDatasetInfoDlg.m_Brand;
				Wineinfo+=m_Brand;
				m_Comfrom=L"管理员";
				SYSTEMTIME tm;		
				GetDirTime(m_SpecDataFoldPath,tm);			
				ReceiveDate.Format(L"%d-%d-%d",tm.wYear,tm.wMonth,tm.wDay);			
			}
			else
			{
				m_ary_SpecFilePath.RemoveAll();
				m_ary_SpecFileName.RemoveAll();
				m_ary_PicturesPath.RemoveAll();
				return;
			}
		}
		else
		{
			m_ary_SpecFilePath.RemoveAll();
			m_ary_SpecFileName.RemoveAll();
			m_ary_PicturesPath.RemoveAll();
			return;
		}

	}
	else
	{
		CString strDirExcel=m_ExcelInfoPath;
		//strDirExcel.Replace(L"\\",L"\\\\");
		CExcelOperator ExcelOperator;
		ExcelOperator.LoadExcel(strDirExcel);

		ExcelOperator.GetItem(1,1,L"String",m_WineName);


		ExcelOperator.GetItem(2,1,L"int",m_AlcoholContent);
		Wineinfo+=m_AlcoholContent;
		Wineinfo+=L"度,";
		ExcelOperator.GetItem(3,1,L"String",m_Flavour);
		Wineinfo+=m_Flavour;
		Wineinfo+=L",";
		ExcelOperator.GetItem(4,1,L"String",m_Brand);
		Wineinfo+=m_Brand;

		ExcelOperator.GetItem(5,1,L"Date",m_ProductionDate);
		//Wineinfo+=Wineinfotemp;

		ExcelOperator.GetItem(6,1,L"String",m_BatchNo);
		//Wineinfo+=Wineinfotemp;

		ExcelOperator.GetItem(7,1,L"String",m_Comfrom);
		ExcelOperator.GetItem(8,1,L"Date",ReceiveDate);

		ExcelOperator.ReleaseExcel();
	}


	SortCArrayByFirst(m_ary_SpecFileName,m_ary_SpecFilePath);

	for(int i=0;i<m_ary_SpecFileName.GetCount();i++)
	{
		//CString Current=m_ary_SpecFilePath[i];

		m_ListSpectrumToAdd.InsertItem(i,m_ary_SpecFileName[i]);
		m_ListSpectrumToAdd.SetItemText(i,1,m_WineName);
		m_ListSpectrumToAdd.SetItemText(i,2,Wineinfo);
		m_ListSpectrumToAdd.SetItemText(i,3,m_ProductionDate);
		m_ListSpectrumToAdd.SetItemText(i,4,m_BatchNo);
		m_ListSpectrumToAdd.SetItemText(i,5,m_Comfrom);
		m_ListSpectrumToAdd.SetItemText(i,6,ReceiveDate);
	}

}
int APIENTRY _tWinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPTSTR    lpCmdLine,
                     int       nCmdShow)
{
	UNREFERENCED_PARAMETER(hPrevInstance);
	UNREFERENCED_PARAMETER(lpCmdLine);
	computerName = lpCmdLine; // name of computer identity to use
	MSG msg;
	HACCEL hAccelTable;

	// Initialize global strings
	LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
	LoadString(hInstance, IDC_LOEBNER_CHATBOT, szWindowClass, MAX_LOADSTRING);
	MyRegisterClass(hInstance);

	// Perform application initialization:
	if (!InitInstance (hInstance, nCmdShow))
	{
		return FALSE;
	}

	hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_LOEBNER_CHATBOT));
	strcpy(lastName,"z");
	BROWSEINFO bi = { 0 };
    bi.lpszTitle = _T("Pick a Chatbot Communication Directory ");
    LPITEMIDLIST pidl = SHBrowseForFolder ( &bi );
    TCHAR path[MAX_PATH];
	path[0] = 0;
	pathname = path;
    if ( pidl != 0 )
    {
        // get the name of the folder
        if ( SHGetPathFromIDList ( pidl, path ) )
        {
            printf ( "Selected Folder: %s\n", pathname );
        }

        // free memory used
        IMalloc * imalloc = 0;
        if ( SUCCEEDED( SHGetMalloc ( &imalloc )) )
        {
            imalloc->Free ( pidl );
            imalloc->Release ( );
        }
    }
	
	hwnd = FindWindow(szWindowClass,NULL);
	RECT rect;
	GetClientRect(hwnd, &rect);
	InvalidateRect(hwnd, &rect, TRUE);

	UINT id = SetTimer ( hwnd, 1, 50, TimeCheck ); // 100 ms timeouts
	strcpy(response,"Chatbot beginning initialization");

	// Main message loop:
	while (GetMessage(&msg, NULL, 0, 0))
	{
		if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
		{
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}
	}

	KillTimer( hwnd, id );

	return 0;
}
示例#27
0
//---------------------------------------------------------------------------
int SteemIntro()
{
	EasyStr caption=T("Welcome to Steem"),text;

  text=T("Thank you for running the Steem Engine. We hope you will get many hours of enjoyment from this program. Before you can start there's just a few things to set up.");
#ifdef WIN32
  int Ret;
  MSGBOXPARAMS mbp;
  mbp.cbSize=sizeof(MSGBOXPARAMS);
  mbp.hwndOwner=NULL;
  mbp.hInstance=Inst;
  mbp.dwContextHelpId=0;
  mbp.lpfnMsgBoxCallback=NULL;
  mbp.dwLanguageId=GetUserDefaultLangID();
  mbp.lpszIcon=RCNUM(RC_ICO_APP);

  text+=" ";
  text+=T("Do you want to put a shortcut to Steem in your Start Menu?");
  mbp.lpszCaption=caption;
  mbp.lpszText=text.Text;
  mbp.dwStyle=MB_USERICON | MB_YESNO;
  if (MessageBoxIndirect(&mbp)==IDYES){
    ITEMIDLIST *idl;
    if (SHGetSpecialFolderLocation(NULL,CSIDL_PROGRAMS,&idl)==NOERROR){
      IMalloc *Mal;SHGetMalloc(&Mal);
      EasyStr Path;Path.SetLength(MAX_PATH);
      SHGetPathFromIDList(idl,Path);
      Mal->Free(idl);

      EasyStr ThisExeName=GetEXEFileName();
      CreateDirectory(Path+"\\Steem Engine",NULL);
      CreateLink(Path+"\\Steem Engine\\Steem Engine.lnk",ThisExeName,"The STE Emulating Engine");
      CreateLink(Path+"\\Steem Engine\\Readme.lnk",RunDir+"\\readme.txt","Steem Engine Info");
    }
  }
#elif defined(UNIX)
  alert.set_icons(&Ico64,ICO64_STEEM,&Ico16,ICO16_STEEM);
  if (1==alert.ask(XD,text,caption,T("Continue")+"|"+T("Abort"),0,1)){
		return 1;
  }
#endif

  caption=T("TOS Image");
  text=T("The most important file Steem needs to run is an image of the ST operating system TOS. If you haven't got one you cannot run Steem. They are easily downloadable from the internet, probably from the same place that you downloaded Steem. Alternatively you can get ST programs that will save out the TOS from an ST. After clicking OK find a TOS image file and click open. This setting, and all the other settings you are about to set, can be easily changed at any time when running Steem.");
#ifdef WIN32
	mbp.lpszText=text;
	mbp.lpszCaption=caption;
  mbp.dwStyle=MB_USERICON | MB_OK;
  MessageBoxIndirect(&mbp);
#elif defined(UNIX)
	alert.ask(XD,text,caption,T("Okay"),0,0);
#endif
  LOOP{
#ifdef WIN32
    ROMFile=FileSelect(NULL,T("Select TOS Image"),RunDir,FSTypes(3,NULL),1,true,"img");
#elif defined(UNIX)
		fileselect.set_corner_icon(&Ico16,ICO16_CHIP);
    ROMFile=fileselect.choose(XD,RunDir,"",T("Select TOS Image"),FSM_LOAD | FSM_LOADMUSTEXIST,
    												romfile_parse_routine,".img");
#endif
    if (ROMFile.IsEmpty()) return 1;

    if (load_TOS(ROMFile)==0) break;

    MessageBox((WINDOWTYPE)0,ROMFile+" "+T("is not a valid TOS"),T("Error Loading OS"),
                MB_ICONEXCLAMATION | MB_TASKMODAL | MB_TOPMOST | MB_SETFOREGROUND);
  }


	caption=T("Disk Images");
  text=T("The next few settings regard the way Steem emulates disks. Steem, and all other ST emulators, use files with the extension ST, STT, DIM or MSA on a PC drive for its floppy disks. This is the format most things you download for the ST will be in. If you have some of these files already then you can tell Steem which folder they are in. This will become your home folder and makes it easy to switch disks in and out of drives. If you don't have any then select a suitable folder on your PC hard disk and Steem will create a blank disk for you there.")+"\n\n"+
         T("Click cancel if you'd rather set up the home folder later.");

	bool proceed;
#ifdef WIN32
  mbp.lpszCaption=caption;
  mbp.lpszText=text;
  mbp.dwStyle=MB_USERICON | MB_OKCANCEL;
  Ret=MessageBoxIndirect(&mbp);
  proceed=(Ret==IDOK);
#elif defined(UNIX)
	proceed=!alert.ask(XD,text,caption,T("Okay")+"|"+T("Cancel"),0,1);
#endif

  if (proceed){
  	EasyStr Path;
#ifdef WIN32
    Path=ChooseFolder(NULL,T("Pick a Folder"),RunDir);
    if (Path.Empty()) Path=RunDir;
#elif defined(UNIX)
		fileselect.set_corner_icon(&Ico16,ICO16_FOLDER);
	  Path=fileselect.choose(XD,RunDir,"",T("Pick a Folder"),
	    FSM_CHOOSE_FOLDER | FSM_CONFIRMCREATE,folder_parse_routine,"");
#endif
		if (Path.NotEmpty()){
      DiskMan.HomeFol=Path;
      NO_SLASH(DiskMan.HomeFol);
      DiskMan.DisksFol=DiskMan.HomeFol;

    	bool Found=0;
      {
	      DirSearch ds;
		    if (ds.Find(DiskMan.HomeFol+SLASH+"*.*")){
		    	do{
            if (FileIsDisk(ds.Name)){
							Found=true;
							break;
		    		}
		    	}while (ds.Next());
		    }
	    }

      if (Found==0){
        if (DiskMan.CreateDiskImage(DiskMan.HomeFol+SLASH+T("Blank Disk")+".st",
                                    80*9*2,9,2)){
          FloppyDrive[0].SetDisk(DiskMan.HomeFol+SLASH+T("Blank Disk")+".st");
          FloppyDrive[0].DiskName=T("Blank Disk");
          DiskMan.InsertHistoryAdd(0,FloppyDrive[0].DiskName,FloppyDrive[0].GetDisk(),"");
        }
      }
    }
  }

  caption=T("Hard Drives");
  text=T("Steem can also emulate hard drives on the ST. This isn't as reliable as disk images, but it works for most things. You can have up to 10 hard drives, each one is mapped to a folder on your PC hard drive.")+"\n\n"+
         T("Would you like to select a folder to be ST hard drive C now?");
 	proceed=false;
#ifdef WIN32
  mbp.lpszText=text;
  mbp.lpszCaption=caption;
  mbp.dwStyle=MB_USERICON | MB_YESNO;
  Ret=MessageBoxIndirect(&mbp);
  if (Ret==IDYES){
  	proceed=true;
  }
#elif defined(UNIX)
	proceed=!alert.ask(XD,text,caption,T("Yes")+"|"+T("No"),0,1);
#endif
	if (proceed){
    int Let=0;
    EasyStr Mess[9];
    Mess[0]=T("Would you like to select a folder to be ST hard drive D now?");
    Mess[1]=T("Would you like to select a folder to be ST hard drive E now?");
    Mess[2]=T("Would you like to select a folder to be ST hard drive F now?");
    Mess[3]=T("Would you like to select a folder to be ST hard drive G now?");
    Mess[4]=T("Would you like to select a folder to be ST hard drive H now?");
    Mess[5]=T("Would you like to select a folder to be ST hard drive I now?");
    Mess[6]=T("Would you like to select a folder to be ST hard drive J now?");
    Mess[7]=T("Would you like to select a folder to be ST hard drive K now?");
    Mess[8]=T("Would you like to select a folder to be ST hard drive L now?");
    EasyStr Path=RunDir;
#ifdef WIN32
    do{
      Path=ChooseFolder(NULL,T("Pick a Folder"),Path);
      if (Path.Empty()) break;
		  NO_SLASH(Path);

      if (Let>=9) break;
      HardDiskMan.NewDrive(Path);
      mbp.lpszText=Mess[Let++];
      mbp.dwStyle=MB_USERICON | MB_YESNO;
      Ret=MessageBoxIndirect(&mbp);
    }while (Ret==IDYES);
#elif defined(UNIX)
		fileselect.set_corner_icon(&Ico16,ICO16_HARDDRIVE);
		do{
		  Path=fileselect.choose(XD,RunDir,"",T("Pick a Folder"),
		    FSM_CHOOSE_FOLDER | FSM_CONFIRMCREATE,folder_parse_routine,"");
		  if (Path.Empty()) break;
		  NO_SLASH(Path);

      if (Let>=9) break;
      HardDiskMan.NewDrive(Path);
			proceed=!alert.ask(XD,Mess[Let++],caption,T("Yes")+"|"+T("No"),1,1);
		}while(proceed);
#endif
  }

	caption=T("Get Ready For Steem!");
	text=T("Congratulations, Steem is now ready to go. Click on the yellow play button to start emulation. To release the PC mouse press the Pause/Break key. To stop emulation click on the run button again or press Shift + Pause/Break.")+
         "\n\n"+T("Have fun!");

#ifdef WIN32
  mbp.lpszCaption=caption;
  mbp.lpszText=text;
  mbp.dwStyle=MB_USERICON | MB_OK;
  MessageBoxIndirect(&mbp);
  return 0;
#elif defined(UNIX)
	alert.ask(XD,text,caption,T("Okay"),0,0);
  return 0;
#endif
}
示例#28
0
QString Q3FileDialog::winGetExistingDirectory(const QString& initialDirectory,
        QWidget *parent,
        const char* /*name*/,
        const QString& caption)
{
#ifndef Q_OS_WINCE
    QString currentDir = QDir::currentDirPath();
    QString result;
    if (parent)
        parent = parent->window();
    else
        parent = qApp->activeWindow();
    QString title = caption;
    if (title.isNull())
        title = tr("Select a Directory");

    if (parent) {
        QEvent e(QEvent::WindowBlocked);
        QApplication::sendEvent(parent, &e);
        QApplicationPrivate::enterModal(parent);
    }

    QString initDir = QDir::toNativeSeparators(initialDirectory);
    wchar_t path[MAX_PATH];
    wchar_t initPath[MAX_PATH];
    initPath[0] = 0;
    path[0] = 0;
    tTitle = title;
    BROWSEINFO bi;
    bi.hwndOwner = (parent ? parent->winId() : 0);
    bi.pidlRoot = NULL;
    bi.lpszTitle = (wchar_t*)tTitle.utf16();
    bi.pszDisplayName = initPath;
    bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_STATUSTEXT | BIF_NEWDIALOGSTYLE;
    bi.lpfn = winGetExistDirCallbackProc;
    bi.lParam = Q_ULONG(&initDir);
    LPITEMIDLIST pItemIDList = SHBrowseForFolder(&bi);
    if (pItemIDList) {
        SHGetPathFromIDList(pItemIDList, path);
        IMalloc *pMalloc;
        if (SHGetMalloc(&pMalloc) != NOERROR)
            result.clear();
        else {
            pMalloc->Free(pItemIDList);
            pMalloc->Release();
            result = QString::fromWCharArray(path);
        }
    } else
        result.clear();
    tTitle.clear();

    if (parent) {
        QApplicationPrivate::leaveModal(parent);
        QEvent e(QEvent::WindowUnblocked);
        QApplication::sendEvent(parent, &e);
    }

    if (!result.isEmpty())
        result.replace(QLatin1Char('\\'), QLatin1Char('/'));
    return result;
#else
    return QString();
#endif
}
QString qt_win_get_existing_directory(const QFileDialogArgs &args)
{
    QString currentDir = QDir::currentPath();
    QString result;
    QWidget *parent = args.parent;
    if (parent)
        parent = parent->window();
    else
        parent = QApplication::activeWindow();
    if (parent)
        parent->createWinId();

    QDialog modal_widget;
    modal_widget.setAttribute(Qt::WA_NoChildEventsForParent, true);
    modal_widget.setParent(parent, Qt::Window);
    QApplicationPrivate::enterModal(&modal_widget);

    QString initDir = QDir::toNativeSeparators(args.directory);
    wchar_t path[MAX_PATH];
    wchar_t initPath[MAX_PATH];
    initPath[0] = 0;
    path[0] = 0;
    tTitle = args.caption;

#if !defined(Q_WS_WINCE)
    BROWSEINFO bi;
#else
    qt_BROWSEINFO bi;
#endif

    Q_ASSERT(!parent ||parent->testAttribute(Qt::WA_WState_Created));
    bi.hwndOwner = (parent ? parent->winId() : 0);
    bi.pidlRoot = NULL;
    //### This does not seem to be respected? - the dialog always displays "Browse for folder"
    bi.lpszTitle = (wchar_t*)tTitle.utf16();
    bi.pszDisplayName = initPath;
    bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_STATUSTEXT | BIF_NEWDIALOGSTYLE;
    bi.lpfn = winGetExistDirCallbackProc;
    bi.lParam = LPARAM(&initDir);

    qt_win_resolve_libs();
    if (ptrSHBrowseForFolder) {
        LPITEMIDLIST pItemIDList = ptrSHBrowseForFolder((BROWSEINFO*)&bi);
        if (pItemIDList) {
            ptrSHGetPathFromIDList(pItemIDList, path);
            IMalloc *pMalloc;
            if (ptrSHGetMalloc(&pMalloc) == NOERROR) {
                pMalloc->Free(pItemIDList);
                pMalloc->Release();
                result = QString::fromWCharArray(path);
            }
        }
    }
    tTitle = QString();

    QApplicationPrivate::leaveModal(&modal_widget);

    qt_win_eatMouseMove();

    if (!result.isEmpty())
        result.replace(QLatin1Char('\\'), QLatin1Char('/'));
    return result;
}
示例#30
0
BOOL WINAPI CreateProcessW_Hook(LPCWSTR lpApplicationName, LPWSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCWSTR lpCurrentDirectory, LPSTARTUPINFOA lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation)
{
	// If this is not a call to start the 'GTAIV.exe' process then just call the original CreateProcessW
	if(wcscmp(lpApplicationName, L"GTAIV.exe"))
		return g_pfnCreateProcessW(lpApplicationName, lpCommandLine, lpProcessAttributes, lpThreadAttributes, bInheritHandles, dwCreationFlags, lpEnvironment, lpCurrentDirectory, lpStartupInfo, lpProcessInformation);

	// Set the CREATE_SUSPENDED flag in the creation flags
	dwCreationFlags |= CREATE_SUSPENDED;

	// Get the GTA IV install directory from the registry
	char szInstallDirectory[MAX_PATH];
	bool bFoundCustomDirectory = false;

	if(!SharedUtility::ReadRegistryString(HKEY_LOCAL_MACHINE, "Software\\Rockstar Games\\Grand Theft Auto IV", 
										  "InstallFolder", NULL, szInstallDirectory, sizeof(szInstallDirectory)) || 
	   !SharedUtility::Exists(szInstallDirectory))
	{
		if(!SharedUtility::ReadRegistryString(HKEY_CURRENT_USER, "Software\\IVMP", "gtaivdir", NULL, 
											  szInstallDirectory, sizeof(szInstallDirectory)) || 
		   !SharedUtility::Exists(szInstallDirectory))
		{
			if(ShowMessageBox("Failed to retrieve GTA IV install directory from registry. Specify your GTA IV path now?", 
				(MB_ICONEXCLAMATION | MB_OKCANCEL)) == IDOK)
			{
				// Taken from http://vcfaq.mvps.org/sdk/20.htm
				BROWSEINFO browseInfo = { 0 };
				browseInfo.lpszTitle = "Pick a Directory";
				ITEMIDLIST * pItemIdList = SHBrowseForFolder(&browseInfo);

				if(pItemIdList != NULL)
				{
					// Get the name of the selected folder
					if(SHGetPathFromIDList(pItemIdList, szInstallDirectory))
						bFoundCustomDirectory = true;

					// Free any memory used
					IMalloc * pIMalloc = 0;
					if(SUCCEEDED(SHGetMalloc(&pIMalloc)))
					{
						pIMalloc->Free(pItemIdList);
						pIMalloc->Release();
					}
				}
			}

			if(!bFoundCustomDirectory)
			{
				ShowMessageBox("Failed to retrieve GTA IV install directory from registry. Cannot launch IV: Multiplayer.");
				return FALSE;
			}
		}
	}

	// Get the full path to GTAIV.exe
	String strApplicationPath("%s\\GTAIV.exe", szInstallDirectory);

	// Make sure the GTAIV.exe path is valid
	if(!SharedUtility::Exists(strApplicationPath.Get()))
	{
		ShowMessageBox("Failed to find GTAIV.exe. Cannot launch IV: Multiplayer.");
		return FALSE;
	}

	// If we have a custom directory save it
	if(bFoundCustomDirectory)
		SharedUtility::WriteRegistryString(HKEY_CURRENT_USER, "Software\\IVMP", "gtaivdir", szInstallDirectory, strlen(szInstallDirectory));

	// Convert the install directory to unicode
	wchar_t wszInstallDirectory[MAX_PATH];
	int iInstallDirectoryLength = SharedUtility::AnsiToUnicode(szInstallDirectory, strlen(szInstallDirectory), wszInstallDirectory, sizeof(wszInstallDirectory));
	wszInstallDirectory[iInstallDirectoryLength] = '\0';

	// Convert the application path to unicode
	wchar_t wszApplicationPath[MAX_PATH];
	int iApplicationPathLength = SharedUtility::AnsiToUnicode(strApplicationPath.Get(), strApplicationPath.GetLength(), wszApplicationPath, sizeof(wszApplicationPath));
	wszApplicationPath[iApplicationPathLength] = '\0';

	// Create the process
	BOOL bReturn = g_pfnCreateProcessW(wszApplicationPath, lpCommandLine, lpProcessAttributes, lpThreadAttributes, bInheritHandles, dwCreationFlags, lpEnvironment, wszInstallDirectory, lpStartupInfo, lpProcessInformation);

	if(bReturn)
	{
		// Get the full path of the client dll
		String strLibraryPath(SharedUtility::GetAbsolutePath(CLIENT_CORE_NAME DEBUG_SUFFIX LIBRARY_EXTENSION));

		// Inject Client.dll into GTAIV.exe
		int iReturn = SharedUtility::InjectLibraryIntoProcess(lpProcessInformation->hProcess, strLibraryPath.Get());

		// Did the injection fail?
		if(iReturn > 0)
		{
			// Terminate the process
			TerminateProcess(lpProcessInformation->hProcess, 0);
			String strError("Unknown error. Cannot launch IV: Multiplayer.");

			if(iReturn == 1)
				strError = "Failed to write library path into remote process. Cannot launch IV: Multiplayer.";
			else if(iReturn == 2)
				strError = "Failed to create remote thread in remote process. Cannot launch IV: Multiplayer";
			else if(iReturn == 3)
				strError = "Failed to open the remote process, Cannot launch IV: Multiplayer.";

			ShowMessageBox(strError.Get());
			return FALSE;
		}

		// Resume the GTAIV.exe thread
		ResumeThread(lpProcessInformation->hThread);
	}

	return bReturn;
}