『壹』 電腦如何知道程序訪問文件夾
通過核心提供的一些API介面,因為文件操作都是要經過這些介面的,所以操作系統會知道的
『貳』 如何查看文件夾被什麼程序使用
工具/原材料
電腦。
1、在電腦的任務管理器頁面中,點擊「性能」按鈕;
『叄』 linux查看哪些程序在使用目錄
1.列出文件清單命令:ls ls命令能夠列出當前目錄下的所有內容。ls 命令的執行方式為: # ls [-選項] [文件名或者目錄名] 進入到Linux命令行中後,我們至少要知道當前所處的位置有哪些內容,這些信息就可以使用ls命令來獲得。
『肆』 如何跟蹤一個程序訪問的文件
process monitor就行(它相當於以前的文件監控用的filemon加註冊表監控regmon的合集) ,用這個軟體可以監控到其它軟體在運行時訪問的各種文件和注冊表,也可以針對性的只過濾出某一類操作,比如僅僅只限寫入。
『伍』 VC 如何根據進程名稱找程序的目錄
你首先需要為VC下載一個Microsoft
Platform
SDK
for
Windows
XP
SP2,有了這個包以後,將psapi.h和psapi.lib拷貝到VC的include和lib目錄,採用PSAPI編程:
1、用EnumProcesses函數列出當前所有進程
2、用OpenProcess打開進程
3、用GetProcessImageFileName函數就可以獲取程序的完整目錄
上面三個函數的資料在互聯網上很完整,你可以用函數名作為關鍵字搜索一下就知道了。
下面舉個例子:
#include
<windows.h>
#include
<stdio.h>
#include
<tchar.h>
#include
<psapi.h>
#pragma
comment(lib,
"psapi.lib")
void
PrintProcessNameAndID(
DWORD
processID
)
{
TCHAR
szProcessName[MAX_PATH]
=
TEXT("<unknown>");
TCHAR
szProcessPath[MAX_PATH]
=
TEXT("<unknown>");
//
獲取進程句柄
HANDLE
hProcess
=
OpenProcess(
PROCESS_QUERY_INFORMATION
|
PROCESS_VM_READ,
FALSE,
processID
);
//
獲取進程名稱和路徑
if
(NULL
!=
hProcess
)
{
HMODULE
hMod;
DWORD
cbNeeded;
if
(
EnumProcessMoles(
hProcess,
&hMod,
sizeof(hMod),
&cbNeeded)
)
{
GetMoleBaseName(
hProcess,
hMod,
szProcessName,
sizeof(szProcessName)/sizeof(TCHAR)
);
}
GetProcessImageFileName(hProcess,
szProcessPath,
MAX_PATH);
}
//
列印進程名、進程號和路徑地址.
_tprintf(
TEXT("%s
(PID:
%u)
<%s>\n"),
szProcessName,
processID,
szProcessPath
);
CloseHandle(
hProcess
);
}
void
main(
)
{
//
獲取進程列表.
DWORD
aProcesses[1024],
cbNeeded,
cProcesses;
unsigned
int
i;
if
(
!EnumProcesses(
aProcesses,
sizeof(aProcesses),
&cbNeeded
)
)
return;
//
計算當前一共多少個活動進程
cProcesses
=
cbNeeded
/
sizeof(DWORD);
//列印進程信息
for
(
i
=
0;
i
<
cProcesses;
i++
)
if(
aProcesses[i]
!=
0
)
PrintProcessNameAndID(
aProcesses[i]
);
}
『陸』 Java獲取程序運行的當前工作目錄
使用下面這個PathUtil的getProgramPath()就可以獲得當前程序運行的目錄。
import java.net.URL;
import java.net.URLDecoder;
class PathUtil {
/**
* Get the env of windir, such as "C:\WINDOWS".
*
* @return the env of windir value.
*/
public static String getWindir() {
return System.getenv("windir");
}
/**
* Get file separator, such as "/" on unix.
*
* @return the separator of file.
*/
public static String getFileSeparator() {
return System.getProperty("file.separator");
}
/**
* Get line separator, such as "\n" on unix.
*
* @return the separator of line.
*/
public static String getLineSeparator() {
return System.getProperty("line.separator");
}
/**
* Get programPath
*
* @return programPath
*/
public static String getProgramPath() {
Class<PathUtil> cls = PathUtil.class;
ClassLoader loader = cls.getClassLoader();
//
// Get the full name of the class.
//
String clsName = cls.getName() + ".class";
//
// Get the package that include the class.
//
Package pack = cls.getPackage();
String path = "";
//
// Transform package name to path.
//
if (pack != null) {
String packName = pack.getName();
//
// Get the class's file name.
//
clsName = clsName.substring(packName.length() + 1);
//
// If package is simple transform package name to path directly,
// else transform package name to path by package name's
// constituent.
//
path = packName;
if (path.indexOf(".") > 0) {
path = path.replace(".", "/");
}
path = path + "/";
}
URL url = loader.getResource(path + clsName);
//
// Get path information form the instance of URL.
//
String retPath = url.getPath();
//
// Delete protocol name "file:" form path information.
//
try {
int pos = retPath.indexOf("file:");
if (pos > -1) {
retPath = retPath.substring(pos + 5);
}
//
// Delete the information of class file from the information of
// path.
//
pos = retPath.indexOf(path + clsName);
retPath = retPath.substring(0, pos - 1);
//
// If the class file was packageed into JAR e.g. file, delete the
// file name of the corresponding JAR e.g..
//
if (retPath.endsWith("!")) {
retPath = retPath.substring(0, retPath.lastIndexOf("/"));
}
retPath = URLDecoder.decode(retPath, "utf-8");
} catch (Exception e) {
retPath = null;
e.printStackTrace();
}
return retPath;
}
}
測試類:
public class Test{
public static void main(String args[]){
String s = PathUtil.getProgramPath();
System.out.println(s);
}
}
『柒』 java怎麼獲取程序所在根目錄
System.getProperty("user.dir");這個試試
『捌』 怎樣知道哪個程序正在訪問文件
可以用「冰刃」。。
UNLOCKER也不錯的。。只不過簡單一些
冰刃操作上要復雜一些。。不過很詳細。。
『玖』 Linux如何查看進程訪問哪個文件
1.查進程
ps命令查找與進程相關的PID號:
ps
a
顯示現行終端機下的所有程序,包括其他用戶的程序。
ps
-A
顯示所有程序。
ps
c
列出程序時,顯示每個程序真正的指令名稱,而不包含路徑,參數或常駐服務的標示。
ps
-e
此參數的效果和指定"A"參數相同。
ps
e
列出程序時,顯示每個程序所使用的環境變數。
ps
f
用ASCII字元顯示樹狀結構,表達程序間的相互關系。
ps
-H
顯示樹狀結構,表示程序間的相互關系。
ps
-N
顯示所有的程序,除了執行ps指令終端機下的程序之外。
ps
s
採用程序信號的格式顯示程序狀況。
ps
S
列出程序時,包括已中斷的子程序資料。
ps
-t<終端機編號>
指定終端機編號,並列出屬於該終端機的程序的狀況。
ps
u
以用戶為主的格式來顯示程序狀況。
ps
x
顯示所有程序,不以終端機來區分。
最常用的方法是ps
a
...
『拾』 您好,請問c++如何讀取此時運行程序的所在目錄
獲取當前目錄的方法有很多,其中之一:
TCHAR szFilePath[MAX_PATH + 1];
GetMoleFileName(NULL, szFilePath, MAX_PATH);
(_tcsrchr(szFilePath, _T('//')))[1] = 0; //刪除文件名,只獲得路徑
CString str_url = szFilePath; //str_url 中保存的是當前目錄