小编Sam*_*Sam的帖子

PowerShell脚本参数作为数组传递

编辑:我已经将代码更改为一个简单的测试用例,而不是出现此问题的完整实现.

我试图从另一个脚本中调用一个Powershell脚本,但事情并没有像我期待的那样成功.据我所知,"&"运算符应该将数组扩展为不同的参数.那不是我的事.

caller.ps1

$scriptfile = ".\callee.ps1"
$scriptargs = @(
    "a",
    "b",
    "c"
)

& $scriptfile $scriptargs
Run Code Online (Sandbox Code Playgroud)

callee.ps1

Param (
    [string]$one,
    [string]$two,
    [string]$three
)

"Parameter one:   $one"
"Parameter two:   $two"
"Parameter three: $three"
Run Code Online (Sandbox Code Playgroud)

.\caller.ps1在以下输出中运行结果:

Parameter one:   a b c
Parameter two:
Parameter three:
Run Code Online (Sandbox Code Playgroud)

我认为我遇到的问题是 $scriptargs数组没有扩展,而是作为参数传递.我正在使用PowerShell 2.

如何让caller.ps1运行带有参数数组的callee.ps1?

powershell

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

纯C中的Win32 COM编程

我有一个编程项目,需要访问一些较低级别的Windows API(特别是WASAPI).我相当有更高层次的编程语言,如C#,Java和PHP经验,我知道只有C/C一点点++.

我想在这个项目中使用C(而不是C++),因为C++有点可怕.在Visual Studio中更改我的项目的C/C++设置以编译为C代码后,我注意到任何调用__uuidof都不起作用,因为它们是C++特定的.

我的问题是双重的:

  1. 是否有可能编写利用COM纯C Win32程序,并
  2. 如果是这样,应该避免使用纯C吗?

c com winapi

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

标签 统计

c ×1

com ×1

powershell ×1

winapi ×1