原文地址:C/C++ Windows API——获取系统指定目录 经测试,在win10 VS2017中用wprintf()输出正常,SHGetSpecialFolderPath函数也正常运行 但是用MinGW(gcc)编译器时,wprintf()函数输出乱码,必须用printf()输出,并且SHGetSpecialFolderPath()运行全部失败…
在Windows平台下获取系统配置文件(如:System.ini)的配置参数. 系统配置文件System.ini的内容如下: [SYSTEM] ServiceIP = 10.128.11.99:60000 CommuType = ShareMemory 代码如下: 包含头文件 Winbase.h (include Windows.h) //GetCurrentPath()函数获取可执行模块的全路径,并将路径中的"\\"变为‘\’,之后去掉了路径中的可执行文件的名字 static voi…
c++中: int cxScreen,cyScreen; cxScreen=GetSystemMetrics(SM_CXSCREEN); cyScreen=GetSystemMetrics(SM_CYSCREEN); c#中: [DllImport("user32")] public static extern int GetSystemMetrics(int nIndex); //获取分辨率宽度 int x = GetSystemMetrics(0); //获取分辨路高度 int y…
转自:http://blog.csdn.net/chy555chy/article 函数 头文件 作用 GetVersionEx <windows.h> 获取系统版本信息(deprecated) VerifyVersionInfo <VersionHelpers.h> 判断当前系统信息是否符合条件 GetComputerName <windows.h> 获取计算机名称 GetUserName <windows.h> 获取用户名 memset <wind…
java获取系统指定时间年月日 private String setDateTime(String falg) { Calendar c = Calendar.getInstance(); c.setTimeInMillis(new Date().getTime()); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat dateMouthFormat = new Simp…
原文:C# API 获取系统DPI缩放倍数跟分辨率大小 using System; using System.Drawing; using System.Runtime.InteropServices; namespace XYDES { public class PrimaryScreen { #region Win32 API [DllImport("user32.dll")] static extern IntPtr GetDC(IntPtr ptr); [DllImport(&…
Windows API中,有一组专门的函数和结构,用于遍历目录,它们是FindFirstFile函数.FindNextFile函数和WIN32_FIND_DATA结构.使用FindFirstFile和FindNextFile函数并与do-while循环结合,可以完成遍历目录的任务.值得一提的是,FindFirstFile输入参数的路径需使用通配符,也就是用户可以根据一些条件来对查找的文件作简单的过滤.下面实例讲解查找特定目录下的所有文件和文件夹.读者可根据自己的需要,指定查找文件的条件. (1)…
系统托盘在我们使用的程序中很普遍,下面我们来看一个很不错的例子,使用Win32 API实现,对理解系统托盘有些帮助. [cpp] view plaincopy #include <windows.h> #define IDR_PAUSE 12 #define IDR_START 13 /* #include <shellapi.h> #pragma   comment(lib,   "shell32.lib") */ LPCTSTR szAppName = TE…
System.getProperty("java.io.tmpdir") 是获取操作系统的缓存临时目录 在windows7中的目录是: C:\Users\登录用户~1\AppData\Local\Temp\ 在linux下的目录是: /tmp 可以获取系统的配置信息,下面说一下System.getProperty()的参数有那些: java.version Java运行时环境版本 java.vendor Java运行时环境供应商 java.vendor.url Java供应商的 URL…
// 使用window api 获得系统时间 // 生成 #include "stdafx.h" #include <Windows.h> #include <direct.h> #include <iostream> int main() { SYSTEMTIME sys; GetLocalTime(&sys); printf("%4d/%02d/%02d %02d:%02d:%02d.%03d 星期%1d\n", \…