Thread: Access Windows directory with OPENFILENAME in Windows mobile

  1. #1
    Registered User
    Join Date
    May 2011
    Posts
    1

    Access Windows directory with OPENFILENAME in Windows mobile

    Hi ALL,

    I need to access Windows and other folders in my Application for Windows Mobile 6.53 through OPENFILENAME. I am able to access \My Documents folder alone.
    But not any other folders under \Windows.

    My Code:
    Code:
    OPENFILENAME ofn;
    	
    	ZeroMemory(&ofn, sizeof(OPENFILENAME));
    	ofn.lStructSize		= sizeof(OPENFILENAME);
    	ofn.hwndOwner		= hwnd;
    	ofn.lpstrFilter		= _T("Application Files (*.exe)\0*.exe\0LNK Files (*.lnk)\0*.lnk\0All Files (*.*)\0*.*\0");
    	ofn.lpstrFile		= filename;
    	ofn.nMaxFile		= MAX_PATH;
    	ofn.nFilterIndex	= 1;
    	ofn.lpstrTitle		= (LPCWSTR)IDS_BROWSEFILE;
    	ofn.lpstrFileTitle	= NULL ;
    	ofn.nMaxFileTitle	= 0 ;
    	ofn.lpstrInitialDir	= _T("\\My Documents\\My Pictures") ;
    	ofn.Flags			= OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_PATHMUSTEXIST | OFN_EXPLORER;
    	return GetOpenFileName(&ofn)
    Pls help.
    Last edited by Salem; 05-28-2011 at 05:35 AM. Reason: added code tags

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    1. Use tags when posting code.

    2. return GetOpenFileName(&ofn)
    Read the manual page, and find out what CommDlgExtendedError is also set to; don't just assume success.

    For one thing, you no longer have blanket permissions to roam all over the file system. \windows is protected, so my guess is you're getting permission denied.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    If not a permission issue...

    IIRC the FILTER string has to be double terminated.

    Because each type of file is delimited by a terminator ('\0') and the whole string has to be terminated (so you need '\0\0' at the end of the filter list).
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Windows mobile
    By AcerN30 in forum C++ Programming
    Replies: 13
    Last Post: 05-02-2008, 10:28 AM
  2. Own a windows mobile pocket pc?
    By AcerN30 in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 04-30-2008, 02:32 PM
  3. c/c++ Windows Mobile Developer Needed
    By ParaDiddle in forum Projects and Job Recruitment
    Replies: 0
    Last Post: 08-02-2007, 07:24 AM
  4. Windows Mobile 5.0 == Windows Mobile 2005?
    By George2 in forum C Programming
    Replies: 4
    Last Post: 08-02-2006, 10:53 PM
  5. windows mobile programming
    By xddxogm3 in forum Windows Programming
    Replies: 2
    Last Post: 12-07-2004, 12:33 AM

Tags for this Thread