Click here to Skip to main content
15,867,308 members
Articles / Programming Languages / Visual C++ 9.0

Project Rename - Rename an Existing Visual Studio Project

Rate me:
Please Sign up or sign in to vote.
4.39/5 (13 votes)
9 Jun 2009CPOL1 min read 58.9K   2.3K   43   13
MFC Application to rename an Existing Visual Studio Project
ProjectRename

ProjRename-11.jpg

Introduction

This is an MFC application that renames Visual C++ Projects.
This application will replace all occurences of "Current Project Name" to "New Project Name" in all files and rename all file names that have "Current Project Name" in it.

This application supports:

  1. VC6 ~ VC9 Projects
  2. Changing the Project GUID
  3. Allows cancel during renaming
  4. UTF-8 files that may be created when the project name was non-english language
  5. Shows elapsed time and failed file list

    ProjRename-12.jpg

This application was developed for Windows XP and uses Windows XP visual style.
The borders of controls like CEdit may not be displayed clearly on Windows Vista.

Usage

  1. Browse the Visual C++ project to rename (*.dsp *.sln)
  2. Enter new project name
  3. Select "Project GUID change" if you want to change the project GUID
    (You can change GUID if you don't like the generated GUID)
  4. Click "Rename" to begin processing

Using the Code

This program is a dialog based application.
It has two views, one is "SelectView" the other is "ProgressView".

C++
BEGIN_MESSAGE_MAP(CProjectRenameDlg, CDialog)
   ON_WM_SYSCOMMAND()
   ON_WM_PAINT()
   ON_WM_QUERYDRAGICON()
   ON_WM_DESTROY()
   ON_MESSAGE(WMU_SELECT_VIEW_CLOSE, OnSelectViewClose)
   ON_MESSAGE(WMU_PROGRESS_VIEW_CLOSE, OnProgressViewClose)
   ON_MESSAGE(WMU_RENAME_FINISHED, OnRenameDone)
   ON_MESSAGE(WMU_RENAME_CANCELED, OnCancelRename)
END_MESSAGE_MAP()

When the user clicked "Rename" to begin renaming, WM_SELECT_VIEW_CLOSE message is sent from "SelectView" and the thread to process is created.

C++
LRESULT CProjectRenameDlg::OnSelectViewClose(WPARAM wParam, LPARAM lParam)
{
   m_pRenameThread = (CRenameThread*)AfxBeginThread
	(RUNTIME_CLASS(CRenameThread), THREAD_PRIORITY_NORMAL, 0, CREATE_SUSPENDED);
   m_pRenameThread->m_bCancel = FALSE;
   m_pRenameThread->m_pOwner = this;
   m_pRenameThread->m_renameOptions = ((CSelectView*)m_pSelectView)->GetRenameOptions();
   m_pRenameThread->ResumeThread();
}

When renaming has been finished, the thread sends WM_RENANE_FINISHED message to notify that renaming has been completed. 

C++
BOOL CRenameThread::InitInstance()
{
    ASSERT(!m_renameOptions.strCurrentPath.IsEmpty());

    // Make list of files to rename
    m_astrFileList.RemoveAll();
    PrepareRename(m_renameOptions.strCurrentPath);

    m_renameStatus.nTotalFiles = m_astrFileList.GetSize();
    m_renameStatus.nCheckedFiles = 0;
    m_renameStatus.nRenamedFiles = 0;
    m_renameStatus.astrErrorList.RemoveAll();
    ProcessRename(m_renameOptions.strCurrentPath);
    return FALSE;
}

int CRenameThread::ExitInstance()
{
    m_pOwner->PostMessage(WMU_RENAME_FINISHED);
    return CWinThread::ExitInstance();
}

History

  • 8 Jun 2009: Version 0.10 Released
  • 9 Jun 2009: Version 0.11 Fixed bug with writing to UFT-8 files

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Korea (Republic of) Korea (Republic of)
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
Questionsill working great in 2020 on VC6.0 Pin
jonnal5-Jan-21 17:47
jonnal5-Jan-21 17:47 
QuestionWorks fine for me - Visual Studion 2008 SP 1.0 Pin
bioan2-Dec-13 4:24
professionalbioan2-Dec-13 4:24 
Generalerror when project including a XML file Pin
maplewang24-Oct-10 21:16
maplewang24-Oct-10 21:16 
GeneralRe: error when project including a XML file Pin
Flying Light27-Oct-10 13:38
Flying Light27-Oct-10 13:38 
GeneralRe: error when project including a XML file Pin
maplewang22-Nov-10 21:23
maplewang22-Nov-10 21:23 
GeneralGot error when running ProjRen.exe Pin
ehaerim15-Jun-09 10:11
ehaerim15-Jun-09 10:11 
GeneralRe: Got error when running ProjRen.exe Pin
merano15-Jun-09 13:54
merano15-Jun-09 13:54 
GeneralRe: Got error when running ProjRen.exe Pin
ehaerim15-Jun-09 14:19
ehaerim15-Jun-09 14:19 
AnswerPlease download static executable Pin
Flying Light15-Jun-09 18:48
Flying Light15-Jun-09 18:48 
AnswerRe: Got error when running ProjRen.exe Pin
merano16-Jun-09 3:47
merano16-Jun-09 3:47 
General#include "res\ProjectRenameDlg.rc2" // non-Microsoft Visual C++ edited resources missing Pin
transoft10-Jun-09 2:12
transoft10-Jun-09 2:12 
AnswerPlease download missing files Pin
Flying Light10-Jun-09 3:00
Flying Light10-Jun-09 3:00 
GeneralWorks fine Pin
Spolm9-Jun-09 22:40
Spolm9-Jun-09 22:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.