有多個工程 我想在工程1用按鈕打開工程2中的表單 應該怎么做 求大神幫助
uj5u.com熱心網友回復:
form2.showuj5u.com熱心網友回復:
剛才試了一下,即使在一個工程組中,也不能跨工程操作物件。樓主你得“換一條路”來實作你的需求。
uj5u.com熱心網友回復:
注意,我說的是都為“EXE工程”的情況。當另一個工程是ActiveX DLL、控制元件工程等時,EXE工程中是可以直接參考另一個工程的控制元件、Class物件的。
這種情況是另一回事,別咬文嚼字的來鉆牛角尖。
uj5u.com熱心網友回復:
我已經將一個工程改成dll然后呢
uj5u.com熱心網友回復:
把工程弄到一個同工程組里面,參考uj5u.com熱心網友回復:
也放到一個作業組了 也設定參考了
uj5u.com熱心網友回復:
之后如何 呼叫工程2的表單啊
uj5u.com熱心網友回復:
CreateRemoteThread
uj5u.com熱心網友回復:
CreateRemoteThread
我是小白不懂 能詳細說一下嗎
uj5u.com熱心網友回復:
CreateRemoteThread
我是小白不懂 能詳細說一下嗎
我就那么一說,你就那么一聽。
uj5u.com熱心網友回復:
如有雷同,純屬炫技:/*
Application: Code Injection in Explorer
Author: @_RT
Compiled on: Feb 2014
URL:http://www.codeproject.com/Tips/732044/Code-Injection-2
We will see the different steps involved to perform a code injection into an already running process.
Following are the quick steps through the process of injection.
1.Get the API addresses that you will be calling from the injected code.
2.Prepare shell code of your function that you want to get executed from the injected process.
3.Get the process ID of the running process that you wish to inject into by enumerating through the
list of processes or by finding the process's window (in case it's a GUI application) by class name or title.
4.Open the process using its Pid with All Access rights.
5.Allocate different memory spaces in the process that you are going to inject to with desired access
rights for holding different segments of your shell code.
Code part (executable instructions)
Data part (strings, function parameters, etc.)
6.Write the allocated memories with the respective values (code and data).
7.Call CreateRemoteThread API and pass to it the start of allocated memory address where you have
written your shell code from the process we are injecting.
*/
#include <windows.h>
#pragma comment(lib,"user32.lib")
LPVOID addr;
LPVOID addr2;
BOOL InjectExecutable(DWORD dwPid,LPVOID si,LPVOID pi,int sisize,int pisize)
{
LPVOID hNewModule;
HANDLE hProcess;
CHAR S[] = { "C:\\Windows\\notepad.exe" };
BYTE byt[] = {0x6A, 0x00, 0x6A, 0x00, 0x6A, 0x00, 0x6A, 0x01, 0x6A, 0x00, 0x6A, 0x00, 0x6A, 0x00, 0x68};
BYTE byt2[] = {0xE8};
BYTE byt3[] = {0x68};
hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, dwPid);
if (hProcess == NULL)
{
return FALSE;
}
LPVOID staddr = VirtualAllocEx(hProcess, NULL, sizeof(S), MEM_COMMIT, PAGE_READWRITE);
WriteProcessMemory(hProcess, staddr, S, sizeof(S), NULL);
LPVOID fnaddr = VirtualAllocEx(hProcess, NULL, 4, MEM_COMMIT, PAGE_READWRITE);
WriteProcessMemory(hProcess, fnaddr, si, sisize, NULL);
LPVOID fnaddr2 = VirtualAllocEx(hProcess, NULL, 4, MEM_COMMIT, PAGE_READWRITE);
WriteProcessMemory(hProcess, fnaddr2, pi, pisize, NULL);
hNewModule = VirtualAllocEx(hProcess, NULL, 100, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
if (hNewModule == NULL)
{
return FALSE;
}
LPTHREAD_START_ROUTINE strtaddr = (LPTHREAD_START_ROUTINE)hNewModule;
WriteProcessMemory(hProcess, hNewModule, byt3, sizeof(byt3), NULL);
hNewModule = (LPVOID)((int)hNewModule + sizeof(byt3));
WriteProcessMemory(hProcess, hNewModule, &fnaddr, sizeof(fnaddr), NULL);
hNewModule = (LPVOID)((int)hNewModule + sizeof(fnaddr));
WriteProcessMemory(hProcess, hNewModule, byt3, sizeof(byt3), NULL);
hNewModule = (LPVOID)((int)hNewModule + sizeof(byt3));
WriteProcessMemory(hProcess, hNewModule, &fnaddr2, sizeof(fnaddr2), NULL);
hNewModule = (LPVOID)((int)hNewModule + sizeof(fnaddr2));
WriteProcessMemory(hProcess, hNewModule, byt, sizeof(byt), NULL);
hNewModule = (LPVOID)((int)hNewModule + sizeof(byt));
WriteProcessMemory(hProcess, hNewModule, &staddr, sizeof(staddr), NULL);
hNewModule = (LPVOID)((int)hNewModule + sizeof(staddr));
WriteProcessMemory(hProcess, hNewModule, byt2, sizeof(byt2), NULL);
hNewModule = (LPVOID)((int)hNewModule + sizeof(byt2));
addr = (LPVOID)((int)addr - ((int)hNewModule + 4));
WriteProcessMemory(hProcess, hNewModule, &addr, sizeof(addr), NULL);
hNewModule = (LPVOID)((int)hNewModule + sizeof(addr));
WriteProcessMemory(hProcess, hNewModule, byt, 2, NULL);
hNewModule = (LPVOID)((int)hNewModule + 2);
WriteProcessMemory(hProcess, hNewModule, byt2, sizeof(byt2), NULL);
hNewModule = (LPVOID)((int)hNewModule + sizeof(byt2));
addr2 = (LPVOID)((int)addr2 - ((int)hNewModule + 4));
WriteProcessMemory(hProcess, hNewModule, &addr2, sizeof(addr2), NULL);
CreateRemoteThread(hProcess, 0, 0, strtaddr, NULL, 0, NULL);
return TRUE;
}
void main()
{
_STARTUPINFOA si;
PROCESS_INFORMATION pi;
ZeroMemory(&si, sizeof(si));
si.cb = sizeof(si);
ZeroMemory(&pi, sizeof(pi));
DWORD dwPid;
HMODULE ldlib = LoadLibraryA("Kernel32.dll");
addr = GetProcAddress(ldlib, "CreateProcessA");
addr2 = GetProcAddress(ldlib, "ExitThread");
GetWindowThreadProcessId(FindWindow(NULL, L"Start Menu"), &dwPid);
InjectExecutable(dwPid,&si,&pi,sizeof(si),sizeof(pi));
}
uj5u.com熱心網友回復:
把工程弄到一個同工程組里面,參考
也放到一個作業組了 也設定參考了
之后如何 呼叫工程2的表單啊
主工程
Private Sub Command1_Click()
Private mobj As Class1
Set mobj = New Class1
mobj.showfrm
End Sub
dll
其中frm2是要顯示的表單
Public Sub showfrm()
frm2.Show 0
End Sub
uj5u.com熱心網友回復:
樓上的都教成這樣了,還是少了點東西。1、創建ActiveDLL工程。
一個Form1,一個Class1。
Class1里
public sub ShowForm()
form1.show
end sub
2、Exe工程,參考上面的工程
在按鈕單擊事件里
dim oForm as new class1
oform.showform
uj5u.com熱心網友回復:
樓上的都教成這樣了,還是少了點東西。
1、創建ActiveDLL工程。
一個Form1,一個Class1。
Class1里
public sub ShowForm()
form1.show
end sub
2、Exe工程,參考上面的工程
在按鈕單擊事件里
dim oForm as new class1
oform.showform
編譯錯誤:未找到方法或資料成員
uj5u.com熱心網友回復:
兩個工程, 兩個程式.相互通訊, 方式很多:
檔案交換, DDE, TCP......
uj5u.com熱心網友回復:
兩個工程的話,最簡單的方法定時器+txt+標識字
uj5u.com熱心網友回復:
最簡單呢,你在工程2中加一個文本框和一個按鈕,工程1編成EXE1運行,工程2是EXE2,然后往工程2的文本框中輸入表單名稱,點擊按鈕,就自動打開工程2對應的表單,這種方式最簡單轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/69915.html
標籤:VB基礎類
