|
This Api Will Help you
DWORD GetModuleFileName(
HMODULE hModule,
LPTSTR lpFilename,
DWORD nSize
);
pass HWND to First parameter.
"I Think this Will Help"
Alok Gupta visit me at http://www.thisisalok.tk
|
|
|
|
|
That won't work. The first parameter is a module handle (an HMODULE ), not a window handle (an HWND ).
Software Zen: delete this;
|
|
|
|
|
With All Due Respect
we Can Type Cast HMODULE with HWND
like
HWND hWnd=this->m_hWnd;
char Filename[200];
GetModuleFileName((HMODULE)hWnd,Filename,199);
"I Think this Will Help"
Alok Gupta visit me at http://www.thisisalok.tk
|
|
|
|
|
That doesn't change the fact that the underlying object for an HMODULE is a module, and an HWND is a window. If you can get away with the type cast, and Windows returns useful information, that's fine. I wouldn't rely on this working in the future, however. This would be an undocumented behavior for the GetModuleFileName API function.
Why not use the correct function: GetWindowModuleFileName() [^]
Software Zen: delete this;
|
|
|
|
|
Sir,With All Due respect,
Correct me if i am wrong
Both HWND and HMODULE are 32 bit Unsigned Long or DWORD
"I Think this Will Help"
Alok Gupta visit me at http://www.thisisalok.tk
|
|
|
|
|
That's true. In Windows, a handle is a token that is used by to identify a specific object. An HWND therefore identifies a window, while an HMODULE identifies a module. When you pass an HWND when Windows expects an HMODULE , it will attempt to use a window handle to identify a module.
For example, let's suppose that handles are implemented as an index within an array. An HWND with the value of 11 would therefore specify the 11th window in the system. An HMODULE with the value of 11 would specify the 11th module in the system. The two aren't related, and you aren't going to get the results you want.
There's an even more obvious example. Suppose that handles are implemented as pointers to a structure. An HWND would therefore point to a structure that defines a window, while an HMODULE would point to a structure for a module. Passing one for the other would obviously have poor results.
While Window handles aren't implemented this way (as far as I know), you should treat them as opaque entities. This implies that, if an API function calls for a handle of a given type, you will only get the expected behavior if you pass a valid handle of that type. If you use a type cast to force the call to receive a handle of another type, then the results are unpredictable.
Software Zen: delete this;
|
|
|
|
|
Yeah Thanks Sir,
Now i understand Difference Between TWO.
Thanks Again
"I Think this Will Help"
Alok Gupta visit me at http://www.thisisalok.tk
|
|
|
|
|
|
you are right about the discussion of HWND and HMODULE. i have got the module name though the GetWindowModuleFileName but it gives the dll file name that explorer.exe is using not the explorer.exe filename.The question is how to get explorer.exe
|
|
|
|
|
Exactly where do u calling this GetWindowModuleName() from a DLL or EXE.
If you are calling from DLL:
Use NULL in Place of HWND or Module , which ever you like
char lpFileName[201];
::GetModuleFileName(NULL,lpFileName,200);
Sorry Sir Gary, from Next time I will use GetWindowModuleName() api.
"I Think this Will Help"
Alok Gupta visit me at http://www.thisisalok.tk
|
|
|
|
|
Hello friends ,
I have a problem in creating dialog boxes, Which has buttons (are created dynamically) and when i click On a button Draw line between two buttons i.e (void DrawLine(int FromButtonId , int ToButtonId) is a function to place the line between the two buttons. I draw the line by setting flags to the Drawline button. the function creates the line but i doesn't view the line when i minimise the dialog box i can able to see the line..after the maximizing the dialog window, I use the Invalidate() function,but it clears all buttons in the dialog box and the line is placed in appropriate position and it blinks..
but i want to place the line as well as buttons in the desired positions.
so plz help me what to do. and how to do..
thanks in advance .
Surya Prakash
|
|
|
|
|
You have to make a logic to do all above in the OnPaint function that takes care of looks of dialog, doing in OnPaint also solves the problem caused by minimizing the dialog.
|
|
|
|
|
how can I create emulator microphone device to play audio file throught it and save in my sound file format?
somebody give me an idea, thanks!!!
Nho'c Ti`
|
|
|
|
|
I think u should look for File format converter.
|
|
|
|
|
Hello!
This is my first post to this forum and english is not my mother tongue, hope you understand me.
I have the following expression
(?:<b>)?(.+?)(?:</b>)
and the string
<b>test</b>
. I am using regex_search function and the match I get is "<b>test". But the first part of the expression "(?:<b>)?" should be greedy, and the "<b>" at the beginning should not be in the match. Am I right?
How should I write the expression to get "test" without "<b>" as the match?
I want to read a word from a webpage, and this word may be between "<b>" and "</b>", but it doesn't have to. This expression is part of a bigger project (part of a bigger expression).
You can download the source code and exe from here http://www.icpnet.pl/~arekrob/regexp2.rar .
Are there any tools to help writing regular expressions compatible with boost regex library?
|
|
|
|
|
try this tool, it's terrific:
http://www.codeproject.com/dotnet/Expresso.asp
About the expression:
I'd use this as an expression:
[<b>]?(.+)?[</b>]?
-- modified 12-Sep-18 21:01pm.
|
|
|
|
|
Thank you for the answer.
This tool is really good, bo unfortunately it isn't compatible with the library I'm using. It returns "test" as the match, not "<b>test". You can see this in the following picture:
http://www.icpnet.pl/~arekrob/regex1.png
I am using Microsoft Visual C++ 6.0 and boost regex library as described here http://www.codeproject.com/string/regex__.asp.
Maybe the library has an error? If that's true what other regular expressions libraries would you recommend? I've tried PCRE but I don't know how to use it in MSVC++ 6 (I found no examples on the Internet).
|
|
|
|
|
Well, then your regex is wrong.
This works fine for me:
([<b>]?.+)</b>
-- modified 12-Sep-18 21:01pm.
|
|
|
|
|
|
I have a question about a linker error when including some libraries in my application.
This is what i have done:
First I have compiled the ximage.lib and png.lib as static libraries and I got no errors.
Then I have linked ximage.lib and png.lib to my application.
When I compile the application I get these linker errors:
ximage.lib(ximapng.obj) : error LNK2019: unresolved external symbol _png_read_row referenced in function "public: bool __thiscall CxImagePNG::Decode(class CxFile *)"
The png_read_row function is declared in the png.lib project, so how can I get these errors when both libraries compiled successfully?
Where should I look for the error, in the png.lib, or in the ximage.lib or should I use some magical setting in the application project?
I hope someone can tell me what I am missing!
Thanks, Dani
|
|
|
|
|
make sure you're putting any #includes from libpng inside extern "C" wrappers:
extern "C" {
#include "png.h"
}
Software | Cleek
|
|
|
|
|
I'm writing a program that needs to capture the Fn key on my laptop, but have not been able to capture it. I've tried using of the keyboard hooking using SetWindowsHookEx, but it doesn't capture the key stroke. Any ideas?
|
|
|
|
|
I recently read on google groups that it's not possible - i've tried to accomplish this recently, too. You'd need to write a very low level keyboard bios (or whatever, i don't know).
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Hi, I have done this in wince, but it should be the same:
Do you have any window or is it a background process?
If you do have a window, the window has to have focus!
You should check the exact messages send in the system using the SPY tool.
Anyway, I have managed to get the hook function to work in wince, but if another application is using the hook function, at least in wince, only one application can hook the keyboard so another call to the hook function will fail.
Try to use this code and put a breakpoint after the case WM_KEYDOWN and see if the WndProc captures the WM_KEYDOWN message.
If it does that check the wparam to see the value when you press the key, you might be looking for the wrong value in wparam that belong to your specifique key press!
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HDC hdc;
int wmId, wmEvent;
PAINTSTRUCT ps;
TCHAR szHello[MAX_LOADSTRING];
switch (message)
{
case WM_KEYDOWN:
switch(wParam){
case 0x00000031:
OutputDebugString(L"Key_1 pressed \n");
break;
}
}
This is wince style so you have to change it a bit!
Try to get focus to your application in the beginning SetFocus(hWnd)!
I hope this help?
Cheers Dani
|
|
|
|
|
How can i create a CStatusBar on a CWnd Parent Window? It doesn't seem to work when I try it.
Thanks
|
|
|
|