小编ary*_*ard的帖子

Powershell命令行参数带有空格和大括号?

我正在尝试我的第一个 powershell 脚本,但在运行以下代码时出现错误参数错误。如何将参数传递给 powersehll 中的命令?

& "bcdedit" /store c:\boot\bcd /set {bootmgr} device partition=C:
Run Code Online (Sandbox Code Playgroud)

编辑: 此操作的工作代码是:

& "bcdedit" /store c:\boot\bcd /set "{bootmgr}" device partition=C:
Run Code Online (Sandbox Code Playgroud)

powershell

5
推荐指数
1
解决办法
5418
查看次数

Powershell:如何读取环境变量?

这是我尝试过的第一个powershell脚本.当我运行它时,第一部分运行良好并创建log.txt,但在再次运行后它仍然运行第1部分.如何检查日志文件是否存在?

编辑:我忘了提到我从PowerShell ISE运行脚本,如果这有所作为.

#Variables.
#Set working directory to scripts location.
$scriptpath = $MyInvocation.MyCommand.Path
$dir = Split-Path $scriptpath

#Check if log file exists.
$ChkFile = "%userprofile%\Desktop\log.txt" 
$FileExists = (Test-Path $ChkFile -PathType Leaf)

#Set dir to script location.
Set-Location $dir

#Part 1.
If (!($FileExists)) 
{
    Write-Host "Part 1"
    echo 0 >>log.txt
}
#Part 2.
ElseIf ($FileExists)
{
    Write-Host "Part 2"
}
Run Code Online (Sandbox Code Playgroud)

powershell

3
推荐指数
1
解决办法
3万
查看次数

如何使用VS11在C程序中嵌入和使用资源文件?

这是我第一次尝试使用资源文件.我已经看到很多适用于C#的答案,但不适用于C.任何建议?

c embedded-resource visual-studio

2
推荐指数
1
解决办法
871
查看次数

这个Arduino代码有什么作用?

但我知道大部分内容都在做什么

    if (digitalRead(miso)) {      d |= 1;    }
Run Code Online (Sandbox Code Playgroud)

是一条我不明白的路线.这些代码来自Adafruit MAX31855库,用于Arduino板.我想在c中将代码移植到我的C8051F020 MCU.该代码从热电偶读取,MAX31855是MCU的数字接口.这是该文件的完整代码.我不熟悉digitalRead().上面发布的if语句是我无法解释的地方.这个if语句在uint32_t Adafruit_MAX31855::spiread32(void)函数中.

        /*************************************************** 
  This is a library for the Adafruit Thermocouple Sensor w/MAX31855K

  Designed specifically to work with the Adafruit Thermocouple Sensor
  ----> https://www.adafruit.com/products/269

  These displays use SPI to communicate, 3 pins are required to  
  interface
  Adafruit invests time and resources providing this open source code, 
  please support Adafruit and open-source hardware by purchasing 
  products from Adafruit!

  Written by Limor Fried/Ladyada for Adafruit Industries.  
  BSD license, …
Run Code Online (Sandbox Code Playgroud)

c++ microcontroller arduino

2
推荐指数
1
解决办法
955
查看次数

在函数输入中附加一个字符?

我需要send和integer到一个函数,然后将它追加到一个常量字符的末尾.

int main (void)
{
    append(1);
}

int append(int input)
{
    const char P = 'P';

    //This where I want to append 1 to P to create "P1"'
}
Run Code Online (Sandbox Code Playgroud)

c

1
推荐指数
1
解决办法
98
查看次数

通过CreateProcessW使用"mkdir"创建的目录名中的垃圾?

运行以下代码后,一切都按照我的意愿进行,除了文件夹显示:test2﷽﷽ꮫꮫꮫꮫووو

这里发生了什么?

            std::string arrString[3] = {" /C mkdir C:\\Users\\Andrew\\Desktop\\test1"," /C mkdir C:\\Users\\Andrew\\Desktop\\test2"," /C mkdir C:\\Users\\Andrew\\Desktop\\test3"};
            LPWSTR cmd =L"C:\\Windows\\System32\\cmd.exe";
            int i;


            for(i=0; i<3; i++)
            {
                STARTUPINFO info={sizeof(info)};
                PROCESS_INFORMATION processInfo;
                vector<wchar_t> cmdline(arrString[i].begin(), arrString[i].end());
                CreateProcessW(cmd, &cmdline[0], NULL, NULL, TRUE, 0, NULL, NULL, &info, &processInfo);
                OutputDebugStringW(L"My output\nstring.");
            }
        }
Run Code Online (Sandbox Code Playgroud)

c c++ winapi

0
推荐指数
1
解决办法
222
查看次数

GetLogicalDrives()for循环

我是win32 api的新手,需要帮助尝试了解GetLogicalDrives()函数的工作原理.我正在尝试使用未使用的所有可用驱动器填充cbs_dropdownlist.这是我到目前为止所拥有的.我将不胜感激任何帮助.

void FillListBox(HWND hWndDropMenu)
{
 DWORD drives = GetLogicalDrives();
 for (int i=0; i<26; i++)
 {
    SendMessage(hWndDropMenu, CB_ADDSTRING, 0, (LPARAM)drives);
 }
}
Run Code Online (Sandbox Code Playgroud)

c c++ winapi

0
推荐指数
1
解决办法
7880
查看次数

是否有一种"更清洁"的方法来设置一组控件的属性而不是这个?

希望学习清理此代码的方法.有没有办法在c#中应用定义的"样式"?我是新手,正在寻找收紧编程的方法.我希望能够以更简洁的方式定义边距,最大值,方向,步进频率,刻度频率,刻度线位置以及到每个滑块的过渡.

        //Slider 1
        Slider Slider_1 = new Slider();
        Slider_1.SetValue(Grid.ColumnProperty, 0);
        Slider_1.Margin = new Thickness(30, 12, 0, 0);
        Slider_1.Orientation = Orientation.Vertical;
        Slider_1.Maximum = 10;
        Slider_1.StepFrequency = 0.25;
        Slider_1.TickFrequency = 0.25;
        Slider_1.TickPlacement = TickPlacement.Outside;
        Slider_1.Transitions = new TransitionCollection();
        Slider_1.Transitions.Add(new EntranceThemeTransition() { });

        //Slider 2
        Slider Slider_2 = new Slider();
        Slider_2.SetValue(Grid.ColumnProperty, 1);
        Slider_2.Margin = new Thickness(30, 12, 0, 0);
        Slider_2.Orientation = Orientation.Vertical;
        Slider_2.Maximum = 10;
        Slider_2.StepFrequency = 0.25;
        Slider_2.TickFrequency = 0.25;
        Slider_2.TickPlacement = TickPlacement.Outside;
        Slider_2.Transitions = new TransitionCollection();
        Slider_2.Transitions.Add(new EntranceThemeTransition() { });

        //Slider …
Run Code Online (Sandbox Code Playgroud)

c#

0
推荐指数
1
解决办法
317
查看次数