|
|
vikrams wrote: bool bRet=CreateProcess("C:\\apps\\Microsoft Office\\OFFICE11\\WINWORD.EXE",
...
if(NULL != bRet)
Why are you checking for NULL when CreateProcess() returns a BOOL value? Change bool to BOOL and compare against TRUE /FALSE .
vikrams wrote: ...it just quits
What quits?
"The greatest good you can do for another is not just to share your riches but to reveal to him his own." - Benjamin Disraeli
|
|
|
|
|
WaitforSingleObject does not wait for WinWord app to finish...it just quits
|
|
|
|
|
I'm not sure what the problem is. I tried your code, along with my two changes, and it works fine.
"The greatest good you can do for another is not just to share your riches but to reveal to him his own." - Benjamin Disraeli
|
|
|
|
|
Hi Guys,
The code works Fine with admin privileges otherwise it fails...
Vikram S
|
|
|
|
|
strangly This admin previleges are needed for Winword.exe only.Excel,notepad and other applications works fine with a normal user account.
|
|
|
|
|
I am trying to program something that I assume is possible. Essentially I want to load a DLL library function in one program (say, program A), and using getprocaddress, I want to call this function from another program, B, purely by using the function's pointer/address.
My question is basically; how do I define and use the DLL function in program B? (only knowing its address in memory.)
|
|
|
|
|
You can't,
The dll's function is loaded into the memory space of program A and only usable from whitin this memory space.
This use to be possible on older OS but when a program crashes it could take other programs to.
Therefore each program has it own memory space where the dll is loaded in for each program.
I think however it is still possible to place some data (contained in the dll) in a shared memory block so that each dll can use this data (dangerous) but I don't think it is possible to do the same with funtion blocks.
codito ergo sum
|
|
|
|
|
if u know the function proto, first typedef it and then create an object of that type. for example if we want to call the
BOOL ShowWindow(HWND hWnd, int nCmdShow);
of User32.dll,
1. typedef its proto
typedef BOOL (WINAPI * myShowWindow)(HWND hWnd,int nCmdShow);
2.Create an object
myShowWindow fun_myShowWindow;
3. Assign the pointer obtained from GetProcAddress() to fun_myShowWindow
$. now u can call the function fun_myShowWindow as usual
eg :- fun_myShowWindow( m_hwnd, SW_SHOW);
nav
|
|
|
|
|
|
Naveen raj mohan wrote: 3. Assign the pointer obtained from GetProcAddress() to fun_myShowWindow
Can I explicitly define an address? Like:
fun_myShowWindow = 0x100021e0; (or something)?
Otherwise I am afraid BadKarma may be right
|
|
|
|
|
pjama wrote: Can I explicitly define an address? Like fun_myShowWindow = 0x100021e0
certainly not...
well, yes, the code would compile, but this will never work, as you cannot know at what address your function will be loaded...
TOXCCT >>> GEII power [toxcct][VisualCalc 2.20][VCalc 3.0 soon...]
|
|
|
|
|
toxcct wrote: you cannot know at what address your function will be loaded
Well, right now, I have the applications messaging eachother via Winsock (TCP). I thought that this could be simplified by sending an initial message containing the function address, and from there the second program could use the functions directly.
I got it to compile shortly after my last message, roughly:
typedef void (*fMultiply)(long,long); <br />
pMultiply = (fMultiply) 0x100021e0;<br />
(pMultiply) (x, y);
There are access problems. Is this the end of the road?
|
|
|
|
|
The function in the DLL does not have a real address until that DLL is loaded into your processes address space. Since a normal DLL cannot be reliably forced into a specific address (it may collide with an already-loaded DLL's load address), you cannot presume what the function's address will be.
Your second program, B, will have to load the DLL into its address space in order to get a valid address for the function.
Going the hack route, you may be able to directly allocate virtual memory in process B, copy the actual code from the function from process A to process B (by some other means), place it into the allocated buffer, set the protection on the buffer to PAGE_EXECUTE_READ , create a suitable function pointer and set it to the address of the buffer, and try to execute it.
-But you are going to have to find out further details about that route on your own...!
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
My application is crashing at customer's computer (Win XP). I've told him to run drwtsn32 -I to get minidump. Although drwtsn said it was installed, after crash there is still only standard "Send report" dialog. Any ideas why drwtsn is not catching the crash ?
Thank you
rrrado
|
|
|
|
|
oh it seems dump was created silently. ok solved
rrrado
|
|
|
|
|
In my VC++ application I want to get a folder opened in windows explorer when its path is given.
Something similar to Find Target..." for a shortcut
Can anybody provide me an example?
Thanks
sss
|
|
|
|
|
Use the ShellExecute() function
nav
|
|
|
|
|
Hi Sandakith !
Here is solution for you. just put the following code, that would do just what you want.
ShellExecute(0,"explore","c:\\malli\\",0,0,SW_SHOWNORMAL);
or
ShellExecute(0,"open","c:\\malli\\",0,0,SW_SHOWNORMAL);
you just go throught the difference between both the solutions, it's a noticable difference. And don't forget to include "windwos.h" and "shellapi.h" files into your project... ! All the best !
- Malli... !
|
|
|
|
|
|
toxcct wrote: prefer using NULL instead of 0...
any Particular Reason Tox for that as NULL is defined as 0 in Windows.h!.. or i am sure you want to increase readibilty of code! am i right?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
readability, definitely !
i know that NULL is 0, because it is actually defined like this :
#define NULL ((void*)0)
but as most C/C++ programmer used to use NULL macro for null pointers, i think it can help reading the code... nothing more.
TOXCCT >>> GEII power [toxcct][VisualCalc 2.20][VCalc 3.0 soon...]
|
|
|
|
|
Thanks all
sss
|
|
|
|
|
I'm trying to create a function which will combine two ints to create a DWORD. Both the ints are a percentage. So far, nothing I have tried is working.
For example, If I pass:
100 and 100 to create a DWORD val of 0xFFFFFFFF.
100 and 50 to create a DWORD val of 0xFFFF7FFF.
0 and 50 to create a DWORD val of 0x00007FFF.
Any help would be greatly appreciated.
|
|
|
|
|
pretty easy :
<font color=blue>DWORD</font> func(<font color=blue>unsigned short</font> paramMSB, <font color=blue>unsigned short</font> paramLSB) {
<font color=green>
<font color=blue>return</font> ((paramMSB * USHRT_MAX / 100) << 16) +
((ParamLSB * USHRT_MAX / 100);
}
cheers,
TOXCCT >>> GEII power [toxcct][VisualCalc 2.20][VCalc 3.0 soon...]
-- modified at 4:41 Tuesday 14th February, 2006
|
|
|
|