DirHash | Windows command line utility to compute hash | File Utils library
kandi X-RAY | DirHash Summary
kandi X-RAY | DirHash Summary
Copyright (c) 2015-2021 Mounir IDRASSI mounir@idrix.fr. 3-clause BSD license ("New BSD License").
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of DirHash
DirHash Key Features
DirHash Examples and Code Snippets
Community Discussions
Trending Discussions on DirHash
QUESTION
This may be 2 questions, but they're broadly both revolving around CreateProcess and it not quite functioning right.
I've been working on an application that gathers together files, processes them, and then zips them as a final step, renaming the zipped file with the hash of the directory that I had zipped. To accomplish this, I'm using a standalone copy of 7zip (7za.exe), by using CreateProcess to create / zip the archive, and a separate program called DirHash to produce the name of the archive I'm trying to make.
The problem I'm having is that neither of these programs are working properly. I'm currently running DirHash with the flags -t "temp.txt" -nowait -quiet -overwrite"
, and it does create a file called temp.txt
, however, the file is always empty when running it using CreateProcess. When I use the exact same parameters on the standard command line, it produces the correct output.
The other issue is that 7zip seems to be erroring when trying to zip my directories. When run through my CreateProcess, I get an "Unsupported Command" error, and the files don't get zipped. However, when I use the exact same parameters on the command line, the archive is created successfully.
Here's the relevant code for DirHash, the same code is used for 7za. I have confirmed that the values given to CreateProcess are correct, and the parameters are the same as the ones I use on the command line.
...ANSWER
Answered 2021-Jan-07 at 15:19When using both the lpApplicationName
and lpCommandLine
parameters of CreateProcess()
, the lpCommandLine
should include the EXE path as the 1st token in the command line. This is even stated in the CreateProcess()
documentation:
If both
lpApplicationName
andlpCommandLine
are non-NULL, the null-terminated string pointed to bylpApplicationName
specifies the module to execute, and the null-terminated string pointed to bylpCommandLine
specifies the command line. The new process can useGetCommandLine
to retrieve the entire command line. Console processes written in C can use theargc
andargv
arguments to parse the command line. Becauseargv[0]
is the module name, C programmers generally repeat the module name as the first token in the command line.
So, if you are going to include the EXE path in the command line, there is no need to use the lpApplicationName
parameter at all:
If
lpApplicationName
is NULL, the first white space–delimited token of the command line specifies the module name. If you are using a long file name that contains a space, use quoted strings to indicate where the file name ends and the arguments begin (see the explanation for thelpApplicationName
parameter )...
Also, rather than converting char
strings to std::wstring
(which you are not doing correctly) just to call CreateProcess()
(which is being mapped to CreateProcessW()
in this situation), you can use CreateProcessA()
instead.
Try this:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install DirHash
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page