|
This question makes no since! What do you mean by "...someone what the address is." Either the code knows what the address is or it doesn't. You might know what the address is at a given run of the program and your debugger might give you the same address every time you rebuild, until you modify the code. But the address may be relitive to the base address of your program or it may be allocated (could be anywhere). You should never need to know the actual address (except maybe when debugging). Pattern searching has nothing to do with finding an address.
struct whatever {...};
struct whatever* pAddr;
or
myfunct(struct whatever* pAddr)
{
}
struct whaterver {...};
whatever* pAddr;
or
myfunct(whatever* pAddr)
{
}
INTP
|
|
|
|
|
Hi:
I want to let the CStatusBar support background bmp(just like CRebar's background).I try to draw the bmp in the onerasebackground() function,but it seems that this way only works in winxp;in win98/me/2000,the background doesn't show correctly.Could you give me any idea or any examplt?
Thanks
Benben
|
|
|
|
|
try OnPaint
Don't try it, just do it!
|
|
|
|
|
|
Hy everybody!
I'm having a little problem in a Windows Service (DOS App)...
I create a CAsyncSocket derived class to work as a server. I use the Listen(), and after that, I wait for a connection on my OnAccept(). Everything works fine... the socket is created, is listening (so I hope)... but when a connection request comes, nothing happens... and don't run the OnAccept mapped function.
(where I'll make Accept() in another socket)
The Unix process (my client) says to me that is connected and begin send data to me... but I even know that I'm connected with it.
Does anybody knows what could be happen?
thanks folks,
cheers!
|
|
|
|
|
Here is a possible cause of your problem:
The OnAccept() method is not called because there is no message pump in your windows service.
Here is my understanding (see MFC source code): When a request comes from a remote program, it is turned into a windows WM_SOCKET_NOTIFY message and posted to an internal window used by CAsynSocket. When the WM_SOCKET_NOTIFY message is processed by MFC, it will invoke the event handlers such as OnAccept, OnReceive, etc. Unless you added a message loop to your windows service, the WM_SOCKET_NOTIFY message will never be processed.
If you cut and paste your code into a MFC dialog based application, assuming there is no other bug, it will work.
If that is confirmed to be the problem, there are at least two relatively easy solutions.
1. Start a separate thread from the windows service. Create the socket in this new thread, call Create/Bind/Listen for the socket, then use a loop to call Accept/Reciev/Send (i.e. don't rely on the OnAccept notification).
2. Move everything to a dialog based application, when the program works, use this special windows service[^] to run your application.
Good luck.
P.S. Solution 1 does not work if multiple clients have to connect to your server simultaneously, in which case you need to add a message pump and rely on the socket events.
My articles and software tools
|
|
|
|
|
Ok, thanks Xiangyang Liu
I'll see if this is the problem, and if so, I'll try one of your sugestions.
Thanks a lot!
cheers!
|
|
|
|
|
The MFC socket classes depend on a message loop to process the notifications properly. Services don't have message loops (normally anyways) so I always use the low level socket routines for services. Check MSDN and they will explain the limitations of CSocket amd CAsyncSocket.
.............................
There's nothing like the sound of incoming rifle and mortar rounds to cure the blues. No matter how down you are, you take an active and immediate interest in life.
|
|
|
|
|
Well, Microsoft Installer (MSI) is a technology (or file format) rather than a tool for authoring installations. InstalShield and Wise produce MSI installations too.
|
|
|
|
|
Hello
Could anyone help me about the "Win 32 error 267" I get when I run a .exe I just correctly compiled with Visual C++?
The associated message is: "Could not execute: invalid directory"
As I'm a beginner, it may be a very stupid mistake....
Thank you in advance
JET
|
|
|
|
|
Is your executable (code) attempting to open a file or a document that does not exist, or does it specify a directory that does not exist ?
That is the apparent reason for the error, so you should check your code throughoghly. Then, set breakpoints into the code and use the debugger to determine the point where this error is caused.
It might also be that your user account has no execution priviledges on the directory where the executable resides. In this case, contact the Systems Administrator for a solution.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Thanks for the answer.
In fact the error happened before the entry point of the program, so no breakpoint could be useful.
It was in fact in options/settings/debug/working directory: as somebody gave me an example of a project, there was something specified that didn't correspond to a real directory on MY computer....
So I erased this line and now I can continue
JET
|
|
|
|
|
I want to ctrl-RClick on a spot and make my cursor change to a custom one (its like a ruler which changes its length depending on which area I click the mouse in). THis cursor image has to be generated on the fly so it cant be part of the resources like an IDI_MYCURSOR. What kind of a file do I need to generate that I can use with SetCursor()? Do I have to "draw" my data into write out a .bmp file onto the hard drive and then reload with ::LoadImage() in my MFC app, to get the handle that I need for ::SetCursor() ? Is there a link on how to make a custom cursor in code somewhere perhaps?
Thanks,
ns
|
|
|
|
|
This sounds very difficult indeed.
Are you certain that it is the cursor length that must change ? Could it be that your cursor can remain a single dot, and then you just purely draw on the device context of the window to achieve your effects ? How about hiding the cursor altogether ?
It is, however, possible to create custom cursor. All you need to do is to create a new, blank icon object and specify two masks for it, AND and XOR. These masks are used to draw the monochrome icon.
For a code example, go to MSDN via this[^] link and expand the second code example there. As you can see, creating run-time icons is a BIG work, but doable.
Read the entire section carefully through before starting, pay especial attention on the truth table used. Then understand that the 4 bytes of each line cover 32 bits of the line (4 * 8 = 32). Then, draw your icon on a paper, and finally, onto the two masks.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Thanks for the link. I was debating on this approach because I thought it would be easier than bitblting onto the surface. I havent done either thing before ....
ns
|
|
|
|
|
hinst
hIcon3 = ::CreateIcon( hinst // application instance
32, // icon width
32, // icon height
1, // number of XOR planes
1, // number of bits per pixel
ANDmaskIcon, // AND bitmask
XORmaskIcon);
How do I get the hinst in MFC?
I didnt see an MFC version of CreateIcon like there is for DrawIcon which I see can be used like CPaintDC dc
dc.DrawIcon()
thanks
Also I want to be able to get rid of the icon using a button or a leftclick or something. This is happening on a picture in an image box, so if theres no obvious way, I can just reload the picture after the icon isnt needed anymore...
doyou think thats the simplest thing to do? What if I ddidnt have a reloadable picture? How would I get rid of the icon then?
Thanks again..
|
|
|
|
|
There is no MFC version, as there is no icon wrapper class (CIcon) for MFC. All this is handled by the CBitmap class, and unfortunately, it does not directly support creation of icons.
Under MFC, you can get the application instance handle by calling a global (macro) function AfxGetInstanceHandle . Alternatively, you can query for AfxGetApp to get the CWinApp class, and use it's CWinApp::m_hInstance data member. The prior function call is a macro wrapper for this approach.
Nothing prevents you from using the Win32 API calls ::CreateIcon and ::DestroyIcon to manage a HICON object in the MFC environment. Note, that the MFC's clean-up framework is not available, so you must be very careful to release and destroy all reserved memory and objects, otherwise your application will cause memory leaks.
You can set the cursor by using ::SetCursor and restore the default cursor by using the same method. Know, though, that for MFC classes derived from CWnd, you must overwrite the CWnd::SetCursor method and determine some sort of a method to decide what cursor to load (by using ::SetCursor).
The default implementation of this function always sends the call down to the base class, and thus, the resulting icon will always be the default one. This manifests itself so that if you call ::SetCursor without overriding the respective method, then the cursor will change, but instantly as you move the mouse (or the cursor), it will be reverted back to the original one.
To restore the icon when it is no longer needed, call ::SetCursor with IDC_ARROW parameter, or pass the call to the base class, which will use the IDC_ARROW as default. After the icon has been detached from the cursor, you can destroy it (the icon) and free the memory it reserved.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Thank you for the detailed answer. Appreciate it .
ns
|
|
|
|
|
I am trying to hook a 3rd Party Window.
Just a little background:
After I get the handle of this window, I use the 'GetWindowThreadProcessId' to get the Thread Id of the window.
Code:
dwThreadId = ::GetWindowThreadProcessId(hwndTskMgr, NULL);
-----------------------------------------------------------------------------
Then I am calling the 'SetWindowsHookEx' function.
Code:
g_hhook = ::SetWindowsHookEx(WH_GETMESSAGE, GetMsgProc, g_hinstDll, dwThreadId);
-----------------------------------------------------------------------------
In function 'GetMsgProc', I am trying to monitor the 'SB_SETTEXT' or 'WM_SETTEXT' message to be able to detect when the ‘3rd Party Window’ sets the text of the status bar.
Code:
LRESULT CALLBACK GetMsgProc(int code, WPARAM wParam, LPARAM lParam)
{
char msg5[255];
wsprintf(msg5, "Inside GetMsgProc & code = %d",code);
::OutputDebugString(msg5); // Just a test
if (code < 0)
{
return CallNextHookEx(g_hhook, code, wParam, lParam);
}
if ((code == HC_ACTION) && (wParam == PM_REMOVE))
{
::OutputDebugString("In code is HC"); // Just a test
MSG *pMsg = (MSG*)lParam;
if(pMsg->message == WM_SETTEXT)
::OutputDebugString("WM_SETTEXT was found\n");
else
::OutputDebugString("WM_SETTEXT was not found\n");
}
return CallNextHookEx(g_hhook, code, wParam, lParam);
}
-----------------------------------------------------------------------------
Problem:
In 'SetWindowsHookEx' I am using 'WH_GETMESSAGE' type of hook procedure, which would give a call to 'GetMsgProc'.
But the CALLBACK GetMsgProc function is not getting called. And some time the GetMsgProc function gets called but my whole system gets stuck up and hangs. And then I need to restart the system.
I have gone through a lot of code in 'CodeGuru.com' as well as in 'CodeProject.com', and have tried many combinations but still am not able to hook the various messages of the Task Manager. I am not able to figure out where I am going wrong.
Any help in this regard would be really appreciated.
|
|
|
|
|
Hello.
I have the dialog based application. I changed the dialog color in the InitInstance function using the following code: SetDialogBkColor(RGB(224, 235, 244));
I added the menu to the dialog. The color of the menu bar is not changed, it's still gray as was before.
How can I change the menu bar color?
Thank you in advance,
Olga Sayenko (olga@nisko.co.il).
|
|
|
|
|
The Menu-Bar is part of the Window's Non-client-Area. Only the Window's Client-Area is affected by the color you specified in SetDialogBkColor.
Changing the menu-bar's color is not supported without some headache, which consists of taking-over OnNcPaint() and somehow clearing the meu-bar-area to your selected color...
I think there was a codeproject article that talked about a hacky way to do this, but I can't find it...
BEHATZLAHA
|
|
|
|
|
dear all
In windows, from explorer, by clicking the right button
we can see the file properties, including the owner of the file.
How can I get that properties by the program in VC++,
I need the owner and also the property of access authority
such as : read only, read write etc
I am looking forward your reply
regards
hb.sapto nugroho
sapto@fstream.net
|
|
|
|
|
Are you talking about GetFileAttributes() ?
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
I am not sure if file owner and
file acess authority (readonly, readwrite,etc)
are in GetFileAttributes.
If the properties that I mean are also
can be taken by GetFileAttributes,
then tell me how to coding it.
regards
|
|
|
|
|
hb.sapto nugroho wrote:
I am not sure if file owner and
file acess authority (readonly, readwrite,etc)
are in GetFileAttributes.
Use GetNamedSecurityInfo() and LookupAccountSid() for owner. Use GetFileAttributes() for the other two.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|