4
你好,我嘗試從系統調用的CreateProcess與golang
func CreateProcess(appName *uint16, commandLine *uint16, procSecurity *SecurityAttributes, threadSecurity *SecurityAttributes, inheritHandles bool, creationFlags uint32, env *uint16, currentDir *uint16, startupInfo *StartupInfo, outProcInfo *ProcessInformation) (err error)
調用CreateProcess的,但我得到了錯誤NUM 123(「文件名,目錄名或卷標語法不正確。」)的路徑calc.exe是正確的。
package main
import (
"fmt"
"syscall"
)
func main() {
var pS syscall.SecurityAttributes
var tS syscall.SecurityAttributes
var iH bool = true
var cF uint32
var env uint16
var cD uint16
var sI syscall.StartupInfo
var pI syscall.ProccessInformation
var err error
err = syscall.CreateProcess(
syscall.StringToUTF16Ptr("c:\\windows\\system32\\calc.exe"),
syscall.StringToUTF16Ptr(""),
&pS,
&tS,
iH,
cF,
&env,
&cD,
&sI,
&pI)
fmt.Printf("Return: %d\n", err)
}
有你爲什麼不使用Go的更高層次的抽象的原因嗎?即'os/exec'包? https://golang.org/pkg/os/exec/ –
創建過程後,我想用指針到pI(processInformation)來寫內存 –