如何在Application Exit或Exit按钮上退出此场景的进程.
namespace test2
{
public partial class MainForm : Form
{
public MainForm()
{
InitializeComponent();
}
private void MainForm_Load(object sender, EventArgs e)
{
}
private void Startbutton_Click(object sender, EventArgs e)
{
ProcessStartInfo startInfo = new ProcessStartInfo("ffmpeg.exe");
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.Arguments = "-i " + urltext.Text.Trim() + "?fifo_size=1000000 -map 0:p:" + Channeltext.Text.Trim() + " -vcodec copy -acodec copy -f segment -segment_time " + splittimetext.Text.Trim() + " " + filenametext.Text.Trim() + "-%03d.ts";
System.Diagnostics.Process.Start(startInfo);
}
}
Run Code Online (Sandbox Code Playgroud)
如何在Application Exit上退出此场景的进程.
问题很简单:Android Fragment是一个不同于Activity的Linux进程吗?
我需要编写一个程序(最好使用高级语言,如 C# 或 Java,但可以是 C/C++),在任何情况下都不能将其数据写入磁盘。
即使不执行任何 I/O 操作,数据也可以通过 OS 页面错误写入磁盘。
有没有办法避免它?
我有一个如下所示的应用程序,由另一个控制台应用程序通过一个Process.Start()方法(即通过两个参数)在一个循环中触发两次.这里有第三种方法Lastmethod();将发送邮件包含输出startfirst();和 startsecond();.但我不要在完成前两种方法之后,我不知道如何触发第三种方法.我设置了两个标志,但是通过发送部分结果的邮件(没有完成前两个方法)显示有些时候是正确的并且有时错误的结果
static void Main(string[] args)
{
bool first = false;
bool second = false;
if (args[0] == "test")
{
startfirst();//time consuming process which will trigger internal child process
first = true;
}
if (args[0] == "finish")
{
startsecond();//time consuming process which will trigger internal child process
second =true;
}
if(first && second)
{
Lastmethod();
}
Console.ReadLine();
}
private static void Lastmethod()
{
//sending mail of the out put of startfirst(); and startsecond(); …Run Code Online (Sandbox Code Playgroud) 我在java中开发了一个应用程序.我需要我的java程序不会终止任何进程资源管理器/任务管理器.
我明白了 将第一个命令的输出传递给第二个命令的stdin.两个过程如何关联?
这是测试fork()系统调用的C代码:
#include<stdio.h>
#include<stdlib.h>
#include<sys/types.h>
#include<unistd.h>
#include<wait.h>
int main(int argc, char *argv[])
{
printf("I am: %d\n", (int)getpid());
pid_t pid = fork();
printf("fork returned: %d\n", (int)pid);
if (pid < 0)
{
perror("fork failed");
}
if (pid==0)
{
printf("I am the child with pid %d\n", (int)getpid());
sleep(5);
printf("Child exiting...\n");
exit(0);
}
printf("I am the parent with pid %d, waiting for the child\n", (int)getpid());
wait(NULL);
printf("Parent ending. \n");
return 0;
}
Run Code Online (Sandbox Code Playgroud)
终端输出是:
I am: 25110
fork returned: 25111
I am the parent with pid …Run Code Online (Sandbox Code Playgroud) 我正在编写一个程序,以便在用户运行命令提示符时立即跟踪并终止(如果可能,则使用regedit).这是为了阻止用户运行我希望他们没有的命令.
我已经编写了代码,可以查看启动进程的时间并使用QueryFullProcessImageName检查其名称.问题是,如果有人要重命名命令提示符,那么我将无法再通过进程名称检测到它.我检测命令提示符的方式当前是"\ cmd.exe",但显然这不是很安全.
以下是我的代码.为简洁起见,我删除了所有错误检查.如果您需要更清晰,请告诉我.谢谢!
TCHAR exeName[MAX_PATH];
DWORD exeNameSize = MAX_PATH;
//the pid comes into the function as a parameter
HANDLE handle = OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, 0, pid);
if (handle)
{
if (QueryFullProcessImageName(handle, 0, exeName, &exeNameSize))
{
tstring name = exeName;
/*
badProcs would contain the path identifiers such as
"\\cmd.exe" or "\\regedit.exe". This detection is
what I want to make better.
*/
for(int i=0; i < badProcs.size(); i++)
{
if(tstring::npos != name.find(badProcs.at(i)))
{
if(TerminateProcess(handle,0))
OutputDebugString(_T("Process should be dead\n\n"));
}
}
}
CloseHandle(handle); …Run Code Online (Sandbox Code Playgroud) 我想像 Process Hacker 那样卸载程序的 DLL。
我正在获取模块列表,它CreateToolhelp32Snapshot(TH32CS_SNAPMODULE | TH32CS_SNAPALL, dwProcId)允许我MODULEENTRY32包含要卸载的 DLL 的信息。
但是FreeLibrary()或者FreeLibraryAndExitThread()不要做任何事情,因为程序正在使用 dll。这就是为什么我不明白 Process Hacker 在使用过程中是如何做到的。
所以这是我的问题:Process Hacker 如何卸载另一个程序使用的 dll?我试图查看源代码,但找不到任何东西。
现在我知道它会导致程序崩溃,但这不是问题。
[编辑]
CreateProcess创建一个过程(例如,从.exe文件)
CreateFile可以创建/打开文件。如果打开.exe文件,该执行文件将运行。在这种情况下,它等于CreateProcess吗?
在这种情况下有什么区别吗?我是新手,谢谢您!
我正在运行我的java应用程序.它显示在任务管理器的进程选项卡中.我不希望用户杀死这个过程?
如果可能的话,我也不希望我的进程也在进程列表中.
我的应用程序是局域网管理员.我需要记录客户机.如果用户可以杀死我的进程,那么创建这样的应用程序是没有用的.
我想要做的是:
获取所有运行进程的列表:( processName没有.exe)ProcessFullFilePath ProcessMainWindowTitle类似于:
process1 c:\p1.exe TheprocessTitle
..............
Run Code Online (Sandbox Code Playgroud)
非常重要:
我需要工作代码,不会出现任何异常(try catch)
我的代码:
我曾经TLHelp32获得名称列表:
var handler: THandle;
data: TProcessEntry32;
function GetName: string;
var i:byte;
begin
Result := '';
i := 0;
while data.szExeFile[i] <> '' do
begin
Result := Result + data.szExeFile[i];
Inc(i);
end;
end;
begin
Application.ShowMainForm := False;
handler := CreateToolhelp32Snapshot(TH32CS_SNAPALL, 0);
if Process32First(handler, data) then
begin
ShowMessage(GetName());
while Process32Next(handler, data) do
ShowMessage(GetName());
end;
Run Code Online (Sandbox Code Playgroud)
这还不够,
我需要:名称路径标题