有没有一种方便的格式化std::chrono::duration为指定格式的方法?
std::chrono::high_resolution_clock::time_point now, then;
then = std::chrono::high_resolution_clock::now();
// ...
now = std::chrono::high_resolution_clock::now();
auto duration = now - then;
// base in microseconds:
auto timeInMicroSec =
std::chrono::duration_cast<std::chrono::microseconds>(duration);
Run Code Online (Sandbox Code Playgroud)
如何设置格式timeInMicroSec一样ss::ms::us?
我想将一些文件夹权限(设置为只读)更改为ReadWriteExecute!
我写了这段代码,但文件夹权限仍然是只读:
private void ChangePermissions(string folder)
{
string userName = Environment.UserName;
FileSystemAccessRule accessRule = new FileSystemAccessRule(userName, FileSystemRights.FullControl, InheritanceFlags.ContainerInherit
| InheritanceFlags.ObjectInherit, PropagationFlags.None, AccessControlType.Allow);
DirectoryInfo directoryInfo = new DirectoryInfo(folder);
DirectorySecurity directorySec = directoryInfo.GetAccessControl();
directorySec.AddAccessRule(accessRule);
directoryInfo.SetAccessControl(directorySec);
}
Run Code Online (Sandbox Code Playgroud)
如果我想删除此目录,Directory.Delete(folder, true)则会收到以下错误消息:
“对路径‘条目’的访问被拒绝。”
当然,权限仍然是只读的!
这里有什么问题吗?
我有一个包含许多项目的解决方案,其中一些位于解决方案路径之外(我将已编译的dll和pdb复制为带有xcopy的Post-build事件)!
如果我想进入dll,它们位于我的解决方案之外:
"断点当前不会被命中.没有为此文档加载符号"
需要哪些步骤才能调试外部dll?
我试图检索最后5个订单,但我得到了最后5个单位!
Model.Order orderAlias = null;
Model.Unit unitsAlias = null;
Model.Employee employeeAlias = null;
IList<Model.Unit> itemList = null;
using (m_hibernateSession.BeginTransaction())
{
var query = m_hibernateSession.QueryOver<Model.Unit>(() => unitsAlias)
.JoinAlias(() => unitsAlias.OrderRef, () => orderAlias, JoinType.InnerJoin)
.JoinAlias(() => unitsAlias.EmployeeRef, () => employeeAlias, JoinType.InnerJoin);
// add additional filters if set
if (propertiesNames.Keys.Contains("Employee")) query.Where(Restrictions.On(() => employeeAlias.Name).IsLike( "%" + (string)propertiesNames["Employee"] + "%"));
if (propertiesNames.Keys.Contains("Division")) query.Where(() => unitsAlias.Division == (string)propertiesNames["Division"]);
query.Where(() => orderAlias.PONumber != 0).OrderBy(() => orderAlias.PONumber).Desc.Take(5);
itemList = query.List<Model.Unit>();
}
Run Code Online (Sandbox Code Playgroud)
获得最近5个订单的单位需要哪些更改?
谢谢
由于某些原因,Intellisense在我的项目中不是1类(C++)的最新版本(当我调用一个方法时,它引用旧的参数等等)!
我能够编译但是如果有更新Intellesense的选项(刷新本地缓存或其他东西)会没问题吗?
谢谢
根据msdn(http://msdn.microsoft.com/en-us/library/windows/desktop/ms740496 (v=vs.85 ) .aspx)的这篇文章, 结构会根据选择的协议而有所不同!
现在我想使用http://www.intelliproject.net/articles/showArticle/index/check_tcp_udp_port中的代码来检查端口是否打开!
现在我有struct sockaddr如下:
struct sockaddr {
ushort sa_family;
char sa_data[14];
};
Run Code Online (Sandbox Code Playgroud)
但需要这个结论:
struct sockaddr {
short sin_family;
u_short sin_port;
struct in_addr sin_addr;
char sin_zero[8];
};
Run Code Online (Sandbox Code Playgroud)
哪些变化是必要的?
(Ws2_32.lib是链接的,以下包括
#define WIN32_LEAN_AND_MEAN
// sockets
#include "windows.h"
#include <winsock2.h>
#include <ws2tcpip.h>
Run Code Online (Sandbox Code Playgroud)
谢谢
在过去,我总是创建一个这样的地图:
class TestClass
{
private:
std::map<int,int> *mapA;
};
TestClass::TestClass
{
mapA = new std::map<int,int>();
}
TestClass::~TestClass
{
mapA->clear(); // not necessary
delete mapA;
}
Run Code Online (Sandbox Code Playgroud)
所以,现在我在Stackoverflow上阅读了所有地方:尽可能经常地避免使用指针
目前我想创建没有指针和新的地图(不需要自己删除对象,减少内存泄漏的危险)!
class TestClass
{
public:
TestClass() : mapA() // this is also needed?
{};
private:
std::map<int,int> mapA;
};
Run Code Online (Sandbox Code Playgroud)
是否有必要进一步正确创建地图?
感谢您的帮助和/或澄清!
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void)
{
const char *str = "This is a string";
char *strCpy = strdup(str); // new copy with malloc in background
printf("str: %s strCpy: %s\n", str, strCpy);
free(strCpy);
char *anotherStr = "This is another string";
printf("anotherStr: %s\n", anotherStr);
char *dynamicStr = malloc(sizeof(char) * 32);
memcpy(dynamicStr, "test", 4+1); // length + '\0'
printf("dynamicStr: %s\n", dynamicStr);
free(dynamicStr);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
为什么 without malloc 的定义也是可能的,和之间anotherStr有什么区别?anotherStrdynamicStr
当我的表单(AboutForm)显示时,我需要把重点放在这个表单上(用户应该只能点击OK按钮)!
VS2008需要哪种设置?
谢谢!
招呼leon22
在SQlite Manager中直接执行SQL可以运行多个命令吗?(如果插入大量数据,则非常有用)
例如
insert into TestTable (Name, Age) values("Thomas", 25)
insert into TestTable (Name, Age) values("Peter", 29)
...
Run Code Online (Sandbox Code Playgroud)
谢谢