Extansionless Files

This is a discussion on Extansionless Files within the Tech Board forums, part of the Community Boards category; I'm sure you know what I"m talking about, right? Those files that have no extenstion what so ever. There called ...

  1. #1
    Christian
    Join Date
    Mar 2002
    Posts
    618

    Extansionless Files

    I'm sure you know what I"m talking about, right? Those files that have no extenstion what so ever. There called things like build and there formatated text, and are most easly viewed by using wordpad. Ok here his my problem, I want to be able to click the file and have word pad open, and not choice to open with word pad.

    It is quite anoying browsing folders from the open diolog, and I would much rather use My computer and go through the folders of what I just download (for example freetype) and read the documantation.
    I shall call egypt the harmless dragon

    -Isaiah 30.7

  2. #2
    Registered User
    Join Date
    Sep 2002
    Posts
    137
    just save the file with the .txt extension.
    http://uk.geocities.com/ca_chorltonkids

  3. #3
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Simple.... find your "Send To" directory (in the Windows sub tree), and create a shortcut to Wordpad.exe in it. Then, you can right click->Sent To->Wordpad on any file in Explorer (regardless of extension)
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  4. #4
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    Hmm...I know how you feel, every time I get a new install in work or home I have to tinker with the registry to get it to open these files with my beloved TextPad (better than wordpad as it has a hex viewer too )

    To ease my pain as well as yours I just wrote this
    Code:
    //#define UNICODE    //Uncomment if you want a unicode build
    //#define _UNICODE    //Uncomment if you want a unicode build
    #include <windows.h>
    #include <tchar.h>
    
    int WINAPI WinMain(HINSTANCE hInst,HINSTANCE,LPSTR,int){
    
    	//
    	//File Dilaog box
    	//
    
    	OPENFILENAME ofn = {sizeof(OPENFILENAME)};
    	TCHAR szFile[MAX_PATH] = {0};
    	TCHAR *szFilter = _T("WordPad.exe\0wordpad.exe\0Other prog\0*.exe\0"),
    		  *szTitle = _T("Locate Wordpad.exe....or choose another editor");
    
    	ofn.hInstance = hInst;
    	ofn.lpstrFile = szFile;
    	ofn.nMaxFile = MAX_PATH;
    	ofn.lpstrFilter = szFilter;
    	ofn.lpstrTitle = szTitle;
    
    	if(!GetOpenFileName(&ofn))
    		return 1;
    
    	//
    	//String manipulation
    	//
    	TCHAR *szCommString = NULL;
    	HKEY hKey = NULL;
    
    	__try{
    		DWORD dwLen = _tcslen(szFile);
    		dwLen += 8;
    		szCommString = new TCHAR[dwLen];
    		if(!szCommString){
    			MessageBox(HWND_DESKTOP,_T("Memory Error"),NULL,MB_OK);
    			return 1;
    		}
    
    		_tcscpy(szCommString, _T("\""));
    		_tcscat(szCommString,szFile);
    		_tcscat(szCommString,_T("\" \"%1\""));
    
    
    	//
    	//Nasty Registry stuff
    	//
    
    		
    		TCHAR *szUnKnown = _T("\\Unknown\\shell"),
    			  *szUnKnownCom = _T("Unknown\\shell\\edit\\command"),
    			  *szComDef = _T("edit");
    
    		if(RegOpenKey(HKEY_CLASSES_ROOT,szUnKnown,&hKey) != ERROR_SUCCESS){
    			MessageBox(HWND_DESKTOP,_T("Error opening key"),NULL,MB_OK);
    			return 1;
    		}
    
    		if(RegSetValue(hKey,NULL,REG_SZ ,szComDef,_tcslen(szComDef)) != ERROR_SUCCESS){
    			MessageBox(HWND_DESKTOP,_T("Error setting command"),NULL,MB_OK);
    			return 1;
    		}
    	
    		RegCloseKey(hKey);
    		
    		if(RegCreateKey(HKEY_CLASSES_ROOT,szUnKnownCom,&hKey) != ERROR_SUCCESS){
    			MessageBox(HWND_DESKTOP,_T("Error creating command"),NULL,MB_OK);
    			return 1;
    		}
    
    		
    
    		if(RegSetValue(hKey,NULL,REG_SZ ,szCommString,_tcslen(szCommString)) 
    				!= ERROR_SUCCESS){
    			MessageBox(HWND_DESKTOP,_T("Error setting commandline"),NULL,MB_OK);
    			return 1;
    		}
    
    		return 0;
    		
    
    	}
    	__finally{
    		
    		if(hKey)RegCloseKey(hKey);
    		if(szCommString) delete [] szCommString;
    
    	}
    
    	return 0;
    }
    Ok, you need to run VC++, but if you havent got it I included the exe....

    Once you run it, it opens a dialog for you to select the location of Wordpad (if you go to the bottom dropdown there's an option to select any exe file...supposing you drop wordpad ....)...now once you have found your exe, it will edit the registry to add an "edit" option to all files without an extension..also, after running the app, whenever you double click, you will get the doc opened in your chosen editor..

    I tested it on WinXP and it works aok......should also work on other Win32 platforms

    Enjoy (I hope!)
    Attached Files Attached Files

  5. #5
    Christian
    Join Date
    Mar 2002
    Posts
    618
    Thanks fordy I'll try it this afternoon when I am home.
    BTW is Unicode enabled in that version?

    >just save the file with the .txt extension.
    Not possible, not only is it time consuming, some of the files are used in the complation of programs and thus are not supposted to have extenstions. (such as the 5 thousand diffent make files that came with freetype)
    Last edited by Sentaku senshi; 09-27-2002 at 08:32 AM.
    I shall call egypt the harmless dragon

    -Isaiah 30.7

  6. #6
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    Originally posted by Sentaku senshi
    BTW is Unicode enabled in that version?
    No, but you can if you uncomment the 2 includes.....I put it there cuz I'm trying to get into the habit

  7. #7
    Christian
    Join Date
    Mar 2002
    Posts
    618
    I'm lazy, so is there any benif to recompiling the program to use unicode? Please note that I use Borland Command line w/vide. So I'm not sure if the file will work perfectly.
    I shall call egypt the harmless dragon

    -Isaiah 30.7

  8. #8
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    Originally posted by Sentaku senshi
    I'm lazy, so is there any benif to recompiling the program to use unicode? Please note that I use Borland Command line w/vide. So I'm not sure if the file will work perfectly.
    Nah dont bother if you dont want to....UNICODE works only on Win NT/2K/XP and runs a little faster on those os's...it will work fine without

  9. #9
    Christian
    Join Date
    Mar 2002
    Posts
    618
    Thanks fordy, it works whooooooooooo. No hopefully I can post this, and not get another errno.
    I shall call egypt the harmless dragon

    -Isaiah 30.7

  10. #10
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    Originally posted by Sentaku senshi
    Thanks fordy, it works whooooooooooo. No hopefully I can post this, and not get another errno.
    My bill is in the post

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. add source files to embedded VC 4.0
    By George2 in forum C++ Programming
    Replies: 4
    Last Post: 06-13-2006, 03:28 AM
  2. *.cpp and *.h files understanding
    By ElastoManiac in forum C++ Programming
    Replies: 4
    Last Post: 06-11-2006, 04:45 AM
  3. Linking header files, Source files and main program(Accel. C++)
    By Daniel Primed in forum C++ Programming
    Replies: 3
    Last Post: 01-17-2006, 10:46 AM
  4. Multiple Cpp Files
    By w4ck0z in forum C++ Programming
    Replies: 5
    Last Post: 11-14-2005, 01:41 PM
  5. header and source files
    By gtriarhos in forum C Programming
    Replies: 3
    Last Post: 10-02-2005, 03:16 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21