一直困拢我很久的一个问题,今天终于解决了。
就是VS2008建WIN32项目的时候,字符集系统默认设成UNICODE,每次都得手动修改过来,比较繁琐。程序员不就是尽量寻找能偷懒的方法吗?于是上网到处找,百度的找不到,我就去GOOGLE找。
这里给出解决方法:
找到
D:\Program Files\Microsoft Visual Studio 9.0\VC\VCWizards\AppWiz\Generic\Application\scripts\2052\default.js
在文件里面找到如下内容:
function AddSpecificConfig(proj, strProjectName, bEmptyProject, strAppType)
{
try
{
var bMFC = wizard.FindSymbol("SUPPORT_MFC");
var bATL = wizard.FindSymbol("SUPPORT_ATL");
var config = proj.Object.Configurations("Debug");
config.CharacterSet = charSetMBCS; //这里原来是charSetUnicode
if (strAppType == "LIB")
config.ConfigurationType = typeStaticLibrary;
else if (strAppType == "DLL")
config.ConfigurationType = typeDynamicLibrary;
var CLTool = config.Tools("VCCLCompilerTool");
// CLTool.PrecompiledHeaderFile = "$(OutDir)/" + strProjectName + ".pch";
CLTool.RuntimeLibrary = rtMultiThreadedDebugDLL;
var strDefines = CLTool.PreprocessorDefinitions;
if (strDefines != "") strDefines += ";";
strDefines += GetPlatformDefine(config);
strDefines += "_DEBUG";
switch(strAppType)
{
case "CONSOLE":
strDefines += ";_CONSOLE";
if (bMFC)
config.UseOfMFC = useMfcDynamic;
if (bATL)
config.UseOfATL = useATLStatic;
break;
case "LIB":
strDefines += ";_LIB";
if (bMFC)
config.UseOfMFC = useMfcDynamic;
break;
case "DLL":
strDefines += ";_WINDOWS;_USRDLL;";
var strExports = wizard.FindSymbol("UPPER_CASE_SAFE_PROJECT_IDENTIFIER_NAME") + "_EXPORTS";
strDefines += strExports;
if (bMFC)
config.UseOfMFC = useMfcDynamic;
if (bATL)
config.UseOfATL = useATLStatic;
break;
case "WIN":
strDefines += ";_WINDOWS";
if (bMFC)
config.UseOfMFC = useMfcDynamic;
if (bATL)
config.UseOfATL = useATLStatic;
break;
default:
break;
}
CLTool.PreprocessorDefinitions = strDefines;
if (bEmptyProject)
CLTool.UsePrecompiledHeader = pchNone;
CLTool.DebugInformationFormat = debugEditAndContinue;
if (strAppType != "LIB")
{
var LinkTool = config.Tools("VCLinkerTool");
LinkTool.GenerateDebugInformation = true;
LinkTool.LinkIncremental = linkIncrementalYes;
if (strAppType == "DLL" || strAppType == "WIN")
LinkTool.SubSystem = subSystemWindows;
else
LinkTool.SubSystem = subSystemConsole;
}
config = proj.Object.Configurations.Item("Release");
config.CharacterSet = charSetMBCS; //这里原来是charSetUnicode
if (strAppType == "LIB")
config.ConfigurationType = typeStaticLibrary;
else if (strAppType == "DLL")
config.ConfigurationType = typeDynamicLibrary;
var CLTool = config.Tools("VCCLCompilerTool");
CLTool.RuntimeLibrary = rtMultiThreadedDLL;
var strDefines = CLTool.PreprocessorDefinitions;
if (strDefines != "") strDefines += ";";
strDefines += GetPlatformDefine(config);
strDefines += "NDEBUG";
if (bEmptyProject)
CLTool.UsePrecompiledHeader = pchNone;
CLTool.DebugInformationFormat = debugEnabled;
switch(strAppType)
{
case "CONSOLE":
strDefines += ";_CONSOLE";
if (bMFC)
config.UseOfMFC = useMfcDynamic;
if (bATL)
config.UseOfATL = useATLStatic;
break;
case "LIB":
strDefines += ";_LIB";
if (bMFC)
config.UseOfMFC = useMfcDynamic;
break;
case "DLL":
strDefines += ";_WINDOWS;_USRDLL;";
var strExports = wizard.FindSymbol("UPPER_CASE_SAFE_PROJECT_IDENTIFIER_NAME") + "_EXPORTS";
strDefines += strExports;
break;
case "WIN":
strDefines += ";_WINDOWS";
if (bMFC)
config.UseOfMFC = useMfcDynamic;
if (bATL)
config.UseOfATL = useATLStatic;
break;
default:
break;
}
CLTool.PreprocessorDefinitions = strDefines;
if (strAppType != "LIB")
{
var LinkTool = config.Tools("VCLinkerTool");
LinkTool.GenerateDebugInformation = true;
LinkTool.LinkIncremental = linkIncrementalNo;
if (strAppType == "DLL" || strAppType == "WIN")
LinkTool.SubSystem = subSystemWindows;
else
LinkTool.SubSystem = subSystemConsole;
}
}
catch(e)
{
throw e;
}
}