• QtCreator显示Qt无效,提示我们make install的解决办法

    ·

    发布于

    修改于

    在qmake.exe所在目录建立名为qt.conf的文件,并录入以下内容:

    [Paths]
    Prefix=..

  • 赛博恶灵

    ·

    发布于

    修改于


  • ubuntu更改DNS服务器

    ·

    发布于

    修改于

    传统的DNS配置文件(/etc/resolv.conf)中写入的地址是127.0.0.53,直接更改这个地址是没用的,重启还会恢复成127.0.0.53。

    正确的做法是在网络配置文件里直接修改,路径是/etc/netplan/*.yaml。


  • CMAKE MSVC设置C、C++运行库链接方式

    ·

    发布于

    修改于

    New in version 3.15.
    
    Select the MSVC runtime library for use by compilers targeting the MSVC ABI.
    
    The allowed values are:
    
    MultiThreaded
    
    
    Compile with -MT or equivalent flag(s) to use a multi-threaded statically-linked runtime library.
    
    MultiThreadedDLL
    
    
    Compile with -MD or equivalent flag(s) to use a multi-threaded dynamically-linked runtime library.
    
    MultiThreadedDebug
    
    
    Compile with -MTd or equivalent flag(s) to use a multi-threaded statically-linked runtime library.
    
    MultiThreadedDebugDLL
    
    
    Compile with -MDd or equivalent flag(s) to use a multi-threaded dynamically-linked runtime library.
    
    The value is ignored on non-MSVC compilers but an unsupported value will be rejected as an error when using a compiler targeting the MSVC ABI.
    cmake_minimum_required(VERSION 3.15)
    cmake_policy(SET CMP0091 NEW)
    project(my_project)
    
    add_executable(foo foo.c)
    set_property(TARGET foo PROPERTY
                 MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")

  • 用MultiByteToWideChar将文件编码从UTF8转为UTF16

    ·

    发布于

    修改于

    bool utf8_to_utf16(const char *fpath)
    {
        bool ret = false;
        HANDLE fileHandle;
        DWORD fileSize;
        PCHAR fileBuffer = nullptr;
        char16_t* utf16Buffer = nullptr;
        DWORD numberOfBytesRead;
        DWORD numberOfBytesWritten;
        fileHandle = ::CreateFileA(fpath,GENERIC_READ|GENERIC_WRITE,FILE_SHARE_READ,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
        if (fileHandle == INVALID_HANDLE_VALUE)
            return false;
        do
        {
            fileSize = ::GetFileSize(fileHandle,NULL);
            if (fileSize == 0)
                break;
            fileBuffer = new (std::nothrow) CHAR[fileSize];
            if (fileBuffer == nullptr)
                break;
            if (::ReadFile(fileHandle,fileBuffer,fileSize,&numberOfBytesRead,NULL) == FALSE)
                break;
            int result = ::MultiByteToWideChar(
              CP_UTF8,       // Source string is in UTF-8
              MB_PRECOMPOSED | MB_ERR_INVALID_CHARS,        // Conversion flags
              fileBuffer,   // Source UTF-8 string pointer
              fileSize,    // Length of source UTF-8 string, in chars
              NULL,     // Pointer to destination buffer
              0    // Size of destination buffer, in wchar_ts
            );
            if (result == 0)
                break;
            utf16Buffer = new (std::nothrow) char16_t[result];
            if (utf16Buffer == nullptr)
                break;
            result = ::MultiByteToWideChar(
              CP_UTF8,       // Source string is in UTF-8
              MB_PRECOMPOSED | MB_ERR_INVALID_CHARS,        // Conversion flags
              fileBuffer,   // Source UTF-8 string pointer
              fileSize,    // Length of source UTF-8 string, in chars
              (LPWSTR)utf16Buffer,     // Pointer to destination buffer
              result    // Size of destination buffer, in wchar_ts
            );
            if (result == 0)
                break;
            if (::SetFilePointer(fileHandle,0,NULL,FILE_BEGIN) == FALSE)
                break;
            if (::WriteFile(fileHandle,"\xFF\xFE",2,&numberOfBytesWritten,NULL) == FALSE || numberOfBytesWritten !=2 )
                break;
            if (::WriteFile(fileHandle,utf16Buffer,result * sizeof(char16_t),&numberOfBytesWritten,NULL) == FALSE || numberOfBytesWritten != result * sizeof(char16_t))
                break;
            if (::SetEndOfFile(fileHandle) == FALSE)
                break;
            ret = true;
        }while(0);
        if (utf16Buffer)
            delete utf16Buffer;
        if (fileBuffer)
            delete fileBuffer;
        ::CloseHandle(fileHandle);
        return ret;
    }

  • Synthetic SCSI Controller…账户没有权限打开附件…

    ·

    发布于

    修改于

    当我们移动hyper-v虚拟机到新磁盘后,启动虚拟机是会出现下面的提示,意思就是虚拟机的磁盘文件没有权限,只需要用命令行给虚拟磁盘文件添加权限即可解决。

    错误提示
    icacls "C:\testvm\testvm\Virtual Hard Disks\testvm.vhdx" /grant "NT VIRTUAL MACHINE\3C910E28-7885-4BF4-94A5-AC9EA3F62796":(F)
    命令执行

  • Intel X550网卡开启2.5G、5G自动协商

    ·

    发布于

    修改于

    Windows

    Windows自带的X550驱动是支持2.5G、5G自动协商的,但是较新的intel官方驱动是不支持的。这会导致使用较新的intel驱动时,X550网卡插在2.5G交换机上,会反复丢失连接(网卡在红叉和连线状态反复横跳)。在Windows平台上解决起来比较方便,直接在网卡设置里设定速度就可以了。

    Linux

    X550网卡官方说明文档
    修改后的网络启动脚本
    root@truenas[/]# cd /etc/network
    root@truenas[/etc/network]# ls
    if-down.d  if-post-down.d  if-pre-up.d  if-up.d  interfaces  interfaces.d
    root@truenas[/etc/network]# cat interfaces
    # interfaces(5) file used by ifup(8) and ifdown(8)
    # Include files from /etc/network/interfaces.d:
    source /etc/network/interfaces.d/*
    auto enp5s0f0
    iface enp5s0f0 inet dhcp
    pre-up ethtool -s enp5s0f0 advertise 0x1800000001028 || true
    auto enp5s0f1
    iface enp5s0f1 inet dhcp
    pre-up ethtool -s enp5s0f1 advertise 0x1800000001028 || true
    root@truenas[/etc/network]# 

  • 获得服务进程PID

    ·

    发布于

    修改于

    DWORD GetServicePid(PSTR ServiceName)
    {
    	SC_HANDLE ScmHandle;
    	SC_HANDLE SvcHandle;
    	SERVICE_STATUS_PROCESS ServiceStatusProcess;
    	DWORD cbBytesNeeded;
    
    	ScmHandle = OpenSCManagerA(NULL, NULL, SC_MANAGER_CONNECT);
    	if (ScmHandle)
    	{
    		SvcHandle = OpenServiceA(ScmHandle, ServiceName, SERVICE_QUERY_STATUS);
    		if (SvcHandle)
    		{
    			if (QueryServiceStatusEx(SvcHandle, SC_STATUS_PROCESS_INFO, (LPBYTE)&ServiceStatusProcess, sizeof(ServiceStatusProcess), &cbBytesNeeded))
    			{
    				CloseServiceHandle(SvcHandle);
    				CloseServiceHandle(ScmHandle);
    				return ServiceStatusProcess.dwProcessId;
    			}
    			CloseServiceHandle(SvcHandle);
    		}
    		CloseServiceHandle(ScmHandle);
    	}
    	return 0;
    }

  • VS2022编译boost 1.78

    ·

    发布于

    修改于

    全部都是编译为静态库,具体分为动、静态链接C库的Debug版和一个静态链接C库的Release版。

    b2 toolset=msvc-14.3 -–layout=versioned variant=debug link=static threading=multi runtime-link=shared
    b2 toolset=msvc-14.3 -–layout=versioned variant=debug link=static threading=multi runtime-link=static
    b2 toolset=msvc-14.3 -–layout=versioned variant=release link=static threading=multi runtime-link=static

最新