VS2017使用配置目录
桌面应用程序安装配置
安装时勾选c++桌面开发,新建项目时选择c++桌面应用程序,不要选择桌面应用向导。
**修改好看的字体:**工具——选项——环境中的字体和颜色——Consolas,12号
都默认选择(不要勾选安全开发生命周期,SDL检查,这会提高代码的安全级别,编译不易通过),创建桌面应用程序后默认会生成一个有内容的cpp文件:WindowsProject1.cpp,一般能运行,也可以用下面的helloworld程序:
// HelloWindowsDesktop.cpp
// compile with: /D_UNICODE /DUNICODE /DWIN32 /D_WINDOWS /c
#include <windows.h>
#include <stdlib.h>
#include <string.h>
#include <tchar.h>
// Global variables
// The main window class name.
static TCHAR szWindowClass[] = _T("DesktopApp");
// The string that appears in the application's title bar.
static TCHAR szTitle[] = _T("Windows Desktop Guided Tour Application");
HINSTANCE hInst;
// Forward declarations of functions included in this code module:
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
int CALLBACK WinMain(
_In_ HINSTANCE hInstance,
_In_opt_ HINSTANCE hPrevInstance,
_In_ LPSTR lpCmdLine,
_In_ int nCmdShow
)
{
WNDCLASSEX wcex;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon(hInstance, IDI_APPLICATION);
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
wcex.lpszMenuName = NULL;
wcex.lpszClassName = szWindowClass;
wcex.hIconSm = LoadIcon(wcex.hInstance, IDI_APPLICATION);
if (!RegisterClassEx(&wcex))
{
MessageBox(NULL,
_T("Call to RegisterClassEx failed!"),
_T("Windows Desktop Guided Tour"),
NULL);
return 1;
}
// Store instance handle in our global variable
hInst = hInstance;
// The parameters to CreateWindow explained:
// szWindowClass: the name of the application
// szTitle: the text that appears in the title bar
// WS_OVERLAPPEDWINDOW: the type of window to create
// CW_USEDEFAULT, CW_USEDEFAULT: initial position (x, y)
// 500, 100: initial size (width, length)
// NULL: the parent of this window
// NULL: this application does not have a menu bar
// hInstance: the first parameter from WinMain
// NULL: not used in this application
HWND hWnd = CreateWindow(
szWindowClass,
szTitle,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT,
500, 100,
NULL,
NULL,
hInstance,
NULL
);
if (!hWnd)
{
MessageBox(NULL,
_T("Call to CreateWindow failed!"),
_T("Windows Desktop Guided Tour"),
NULL);
return 1;
}
// The parameters to ShowWindow explained:
// hWnd: the value returned from CreateWindow
// nCmdShow: the fourth parameter from WinMain
ShowWindow(hWnd,
nCmdShow);
UpdateWindow(hWnd);
// Main message loop:
MSG msg;
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (int)msg.wParam;
}
// FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
//
// PURPOSE: Processes messages for the main window.
//
// WM_PAINT - Paint the main window
// WM_DESTROY - post a quit message and return
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
PAINTSTRUCT ps;
HDC hdc;
TCHAR greeting[] = _T("Hello, Windows desktop!");
switch (message)
{
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
// Here your application is laid out.
// For this introduction, we just print out "Hello, Windows desktop!"
// in the top left corner.
TextOut(hdc,
5, 5,
greeting, _tcslen(greeting));
// End application-specific layout section.
EndPaint(hWnd, &ps);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
break;
}
return 0;
}
点击小三角图标,运行后结果为:
控制台应用配置
除了指定include目录、lib目录、拷贝动态库到源程序所在文件夹外,在编译程序时还报错(程序本来应该是没问题的):
char * 类型错误
解决办法
在项目属性的C/C++ ——预处理定义中粘贴下列内容:其中前三个一般自带有,着重检查后面的几项
WIN32
_DEBUG
_CONSOLE
_LIB
_MBCS
_CRT_SECURE_NO_WARNINGS
如下图:
Anaconda安装默认路径-换源-配置
打开图标所在位置——右键属性
把末尾的双引号内容删掉,空格,再填充自己的工作目录
最后,目标里面的内容是形容下面的。
D:\ProgramData\Anaconda3\python.exe D:\ProgramData\Anaconda3\cwp.py D:\ProgramData\Anaconda3 D:\ProgramData\Anaconda3\python.exe D:\ProgramData\Anaconda3\Scripts\jupyter-notebook-script.py D:\Anaconda-Jupyter\Project
新建个test文件夹测试,
查看conda是否正常:
conda --version
正常如下:
win下,换源,在Prompt中敲命令:
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
查看换源是否成功:
conda config --show channels
正常结果类似如下:
换豆瓣源
实际操作中,感觉豆瓣源比清华源更快、更稳定。
anaconda换源跳转
更换显示字体和大小
找到安装路径下的文件codemirror.css:D:\ProgramData\Anaconda3\Lib\site-packages\notebook\static\components\codemirror\lib
修改字体和大小属性:
.CodeMirror {
/* Set height, width, borders, and global font properties here */
font-family: Consolas;
height: 400px;
color: black;
direction: ltr;
}