|
It can be done, but involves some amount of work. First, obtain the process id for the window with GetWindowThreadProcessId . Then, use the information contained in MSDN sample MODLIST.EXE Shows How to Enumerate Processes and Modules (Q192986) to enumerate the modules of the given process and its corresponding paths (a process is made of multiple modules, like the main .EXE and the different DLLs loaded). Please note the code differs for 95...ME and NT...XP systems.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi there!
I have some big problems translating one relatively separated dll written in C++ to the managed world because I don't know how to work with the GUID structure. I can't just replace it with the System::Guid structure cause one of my functions which returns guid is used from both worlds, managed and unmanaged.
I'm also getting errors when trying to assign one GUID to another.
The code looks like this:
GUID& GetGuid()
{
GUID guidVar1, guidVar2;
CoCreateGuid(&guidVar1); //error
guidVar = guidVar2; //error
return guidVar; //error
}
Help me please!!!
|
|
|
|
|
How do i keep my widow active all the time?
|
|
|
|
|
I don't know if its help you:
with CWnd::SetWindowPos() you can set your window always on top.
Mazy
"The path you tread is narrow and the drop is shear and very high,
The ravens all are watching from a vantage point near by,
Apprehension creeping like a choo-train uo your spine,
Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd
|
|
|
|
|
Hi,
I have one application that uses MSXML4.dll, what do I need to install on the client's computer in order to make my program run ?, Just copy msxml4.dll on the system folder, and run RegSvr32 ? What about versions and... services packs and.. ?
Thanks, greetings
Braulio
|
|
|
|
|
Legally you must get the runtime distribution and install all of the files in it. You can download it seperatly from the sdk.
Good ideas are not adopted automatically.
They must be driven into practice with courageous patients. -Admiral Rickover. ...
|
|
|
|
|
Does anybody know how to get the access rights (security descriptor) of a directory or a file on the local machine ?
|
|
|
|
|
Use GetSecurityInfo[Ex] and GetNamedSecurityInfo[Ex].
Tomasz Sowinski -- http://www.shooltz.com
- It's for protection - Protection from what? Zee Germans?
|
|
|
|
|
How do i get the handle for the first parameter in GetSecurityInfo()!!
|
|
|
|
|
This is the file handle returned by CreateFile.
Tomasz Sowinski -- http://www.shooltz.com
- It's for protection - Protection from what? Zee Germans?
|
|
|
|
|
Have you ever used the function LogonUser() ??
|
|
|
|
|
|
I allways get the error message: ERROR_PRIVILEGE_NOT_HELD. I know what it means, but i don't know how to fix it! What must i do to get i work!
|
|
|
|
|
Check KB article Q180548
Tomasz Sowinski -- http://www.shooltz.com
- It's for protection - Protection from what? Zee Germans?
|
|
|
|
|
|
i have taken a look at the documentation you mentioned. It works fine, no warnings or errors at all. But the description of that code says that it can be used in the same way like LogonUser().
But where do i see that i works in the same way ?
and
LogonUser() returns a handle to the logged on user, which can be used in CreateProcessAsUser(). Where can i find or get this handle in that sample code ??
|
|
|
|
|
I can't fix the problem for two days.
Any help will be greatly appreciated!!!
I created a new project, chose Win32 Application and checked An empty project. Then Added new cpp file and filled in following codes. The debug result has puzzled me for a long time, for there is no hint at all!!!
Here we go...
#define _WIN32_WINNT 0x0500
#define WIN32_LEAN_AND_MEAN
#include <stdio.h>
#include <stdlib.h>
#include <process.h>
#include <windows.h>
#include <string.h>
#include "..\MtVerify.h"
extern "C"
unsigned WINAPI ThreadFunc(void * p);
HANDLE ghEvent;
#define WM_JOB_PRINT_AS_IS WM_APP + 0x0001
#define WM_JOB_PRINT_REVERSE WM_APP + 0x0002
#define WM_JOB_PRINT_LOWER WM_APP + 0x0003
int main(VOID)
{
HANDLE hThread;
unsigned tid;
ghEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
hThread = (HANDLE) _beginthreadex(NULL,
0,
ThreadFunc,
0,
0,
&tid);
MTVERIFY(hThread);
WaitForSingleObject(ghEvent, INFINITE);
char *szText = strdup("Thank you for buying this book .\n ");
PostThreadMessage(tid, WM_JOB_PRINT_AS_IS, NULL, (LPARAM)szText);
szText = strdup("Text is easier to read forward. \n");
PostThreadMessage(tid, WM_JOB_PRINT_REVERSE, NULL, (LPARAM)szText);
szText = strdup("\nLOWER CASE IS FOR WHISPERING. \n");
PostThreadMessage(tid, WM_JOB_PRINT_LOWER, NULL, (LPARAM)szText);
WaitForSingleObject(hThread, INFINITE);
CloseHandle(hThread);
return 0;
}
VOID CALLBACK TimerFunc(
HWND hwnd,
UINT Msg,
UINT idEvent,
DWORD dwTime)
{
UNREFERENCED_PARAMETER(hwnd);
UNREFERENCED_PARAMETER(&Msg);
PostThreadMessage(GetCurrentThreadId(), WM_QUIT, 0,0);
}
unsigned WINAPI ThreadFunc(LPVOID n)
{
UNREFERENCED_PARAMETER(n);
MSG msg;
PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE);
SetEvent(ghEvent);
SetTimer(NULL, NULL, 2000, (TIMERPROC) TimerFunc);
while(GetMessage(&msg, NULL, 0,0))
{
char *psz= (char *) msg.lParam;
switch(msg.message)
{
case WM_JOB_PRINT_AS_IS:
printf(" the job print as is called %s", psz);
free(psz);
break;
case WM_JOB_PRINT_REVERSE:
printf(" %s ", strrev(psz));
free(psz);
break;
case WM_JOB_PRINT_LOWER:
printf("%s", _strlwr(psz));
free(psz);
break;
default:
DispatchMessage(&msg);
}
}
return 0;
}
Debug result:
--------------------Configuration: www - Win32 Debug--------------------
Compiling...
worker.cpp
J:\MultiThreads\www\worker.cpp(33) : error C2065: '_beginthreadex' : undeclared identifier
Error executing cl.exe.
www.exe - 1 error(s), 0 warning(s)
Best regard.
|
|
|
|
|
You chose the wrong type of app. It should be "Console application" instead of "Win32 application".
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
You didn't tell the compiler you were building for multithreaded. Change that in the settings.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
#include <process.h>, unless it is already one of your other includes. Hard to know, since we don't see them.
Michel
If I am wrong or said something stupid, I apologize in advance
|
|
|
|
|
Though CodeProject is said the most powerful forum, frankly speaking, I am disappointed.
Codeguru forum answered my question. That site rich in experts IN ANSWERING QUESIONS.
I really hope that CodeProject can adopt some advanced ideas in Codeguru.
The problem is:
_beginthreadex is in MFC. I didn't check the "An Application that supports MFC" in step 1 of Creating "Win32 Console Application" Wizard.
Thanks to all who answered my question.
Best regard.
|
|
|
|
|
1. _beginthreadex is NOT part of MFC. Anybody who told you this doesn't know what they are talking about. If you do a search of the VC include files you will find it defined in process.h. This is part of the CRTL. (Which is TOTALLY different than MFC).
#ifdef _MT
_CRTIMP uintptr_t __cdecl _beginthread (void (__cdecl *) (void *),
unsigned, void *);
_CRTIMP void __cdecl _endthread(void);
_CRTIMP uintptr_t __cdecl _beginthreadex(void *, unsigned,
unsigned (__stdcall *) (void *), void *, unsigned, unsigned *);
_CRTIMP void __cdecl _endthreadex(unsigned);
#endif
2. If you are including process.h and still are not getting _beginthreadex, then _MT is not being defined. This is AUTOMATICALLY defined when you build the program for multithreaded operations.
The only reason changing MFC settings would have caused your program to build is that it has also modified your compiler options to build for multithreaded operations.
This is EXACTLY the information we gave you.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Ok, let's put it clear and clean.
I've chosen "Win32 Console Application" and then checked "An Empty Application". My application itself is a single thread. Though I set the "Use Runtime Library" as "Multithreads". The debug results are:
--------------------Configuration: Worker - Win32 Debug---------------
Compiling...
worker.cpp
Linking...
LIBCMT.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16
Debug/Worker.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
Worker.exe - 2 error(s), 0 warning(s)
Somebody said that I'd used the wrong console. I used "Win32 Console Application", and in "An simple application", the app is just as:
// worker09.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
int main(int argc, char* argv[])
{
return 0;
}
There is no such thing like "WinMain()".
There are somethings in your comment, but the problem is still out there.
Best regard.
I confess that I am a stubborn guy, but why not put things thoroughly, logically and systematically clean. A quetion can make one somebody if he takes it really seriously.
One concrete prolem is worth a thousand unapplied abstractions.
|
|
|
|
|
Why CTime Appel(1970,1,1,0,0,0); create a failed insertion???
|
|
|
|
|
What exactly is the problem?
I tried your code in VC6 SP5 (Windows 2000) and it worked okay. What version of compiler are you using?
Michael
|
|
|
|
|