|
There is always a good time to learn!;P ==> ::GetLastError()
The error codes are defined in the "winerror.h" header file. You can also use the FormatMessage if you want to see a text description of the error.
<br />
std::string strMessage;<br />
<br />
HLOCAL hLocal = 0;<br />
::FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER, 0,(DWORD)::GetLastError(), 0, (char*)&hLocal, 0, 0 );<br />
<br />
strMessage = (char*)LocalLock( hLocal );<br />
LocalFree( hLocal );<br />
|
|
|
|
|
srry for the stupid question but how do i look at the error codes in the "winerror.h" header file? honestly this is all a first time for me, thnx for the help though.
|
|
|
|
|
Jebus89 wrote: srry for the stupid question but how do i look at the error codes in the "winerror.h" header file?
Open the file using the IDE, or some other text editor such as Notepad.
Personally, I find that the simplest method to do this sort of thing is to add:
#include <winerror.h> someplace in the code, right click that statement, and select "Open" from the context menu. That'll save you from having to deal with a bunch of (messy) folder names.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
If you're using the Visual Studio debugger then just enter "@ERR, hr " in the watch window and let the debugger do all the heavy lifting.
Steve
|
|
|
|
|
If you aren't, then your compiler will have an "include" folder somewhere within it's parent directory.. Look in there.. "winuser.h" may be in another folder called "win" or in this directory.. i.e. it will either be in "[compiler root directory]\include\" or "[compiler root directory]\include\win".. If you still cannot find it, use the Windows search function (Press Windows key+F)
--PerspX
"Nowadays, security guys break the Mac every single day. Every single day, they come out with a total exploit, your machine can be taken over totally. I dare anybody to do that once a month on the Windows machine." - Bill Gates
|
|
|
|
|
Can you show your code and also see here[^] im not sure its helpful or no.
|
|
|
|
|
srry if i didnt make myself clear, my problem is that i want to inject dll's into a game which recently i can't do because i get the open process failure pop up. the dll's / loader are not mine, i did not write them. all i did was download them. i know that it is something wrong with my computer that is giving me the "Failed to open process on _____" "OpenProcess Failed!" because it has been confirmed by hundreds of other people that the injector / loader works. This problem exists with any injector for any games. I have no prior background in programming so i'm srry if i posted this question in the wrong section but this community seemed to be really helpful so i posted in hopes that som1 could help me identify / fix the problem. thnx!
|
|
|
|
|
then you are in the wrong forum, this is a place for programmers asking other programmers programming questions....honestly i and other have no idea what level of knowledge you have and they are not going to waste their time answering the most primitives of questions,
who wants to keep hearing ya but i don't know how to do that..ad nauseam
sorry can't help you & good luck.
Yours Truly, The One and Only!
|
|
|
|
|
I know that it is possible to declare a class BEFORE the class has actually been constructed and defined. Here is an example:
int main()<br />
{<br />
class CHello;<br />
CHello tmp;<br />
return 0;<br />
}<br />
<br />
class CHello<br />
{<br />
}
As you can see, the line class CHello tell the compiler that such a class exists later on the code. However, how is it possible to declare the functions found within the class in the same way? I tried the code below, and it doesn't work.
int main()<br />
{<br />
class CHello;<br />
void CHello::create();<br />
CHello tmp;<br />
return 0;<br />
}<br />
<br />
class CHello<br />
{<br />
void create()<br />
{<br />
}<br />
}
Any solutions to this problem?
-- modified at 16:14 Sunday 8th July, 2007
Feed Launch .NET
|
|
|
|
|
No - forward declaring classes doesn't even work with your first example, I thought. The idea is you can forward declare a class if all you're doing locally is declaring a pointer, as a pointer has a fixed size in memory, and it can work out the size of the class later. I also didn't think you could declare a class inside a method ?
It's usually used if class A and class B hold references to each other, and so cannot include each others headers, as they recurse and blow up.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Thanks for the quick reply! I just tried the first example out, and it does work. However, thanks for clarifying when and when not to use forward class declarations. I'll try to use pointers instead!
Feed Launch .NET
|
|
|
|
|
When you forward-declare a class, you're just telling the compiler that the name CHello is a class name. You can't actually use CHello or a CHello variable until you define CHello . You can use a CHello* before the definition of CHello , but you can't dereference that pointer.
|
|
|
|
|
Given a HKEY, can the root and subkey hierarchy be determined? I tried using RegQueryInfoKey() using the lpClass parameter in the hope that it would work but it doesn't.
<br />
LPTSTR TempData[4096];<br />
DWORD TempSize = 4096;<br />
<br />
RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows", 0, GENERIC_READ, &TempKey);<br />
RegQueryInfoKey(TempKey, TempData, &TempSize, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);<br />
None of the other registry access functions seem like what I need. I want to be able to take a HKEY as input and generate a string such as "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows" as output.
BTW, what is the lpClass parameter good for? Every HKEY I've tried causes it to return zero bytes of data (TempSize == 0). The function always returns ERROR_SUCCESS.
|
|
|
|
|
|
I am using LoadLibrary to load a dll and then export a function called MGetPixel from it. I load the DLL successfully but the GetProcAddress always gives me errors. Here is my code:
<br />
typedef COLORREF (*MYPROC)(HDC, int, int);<br />
HINSTANCE hinstLib = LoadLibrary("MacAPI.dll");<br />
MYPROC MGetPixel = (MYPROC)GetProcAddress(hinstLib, "MGetPixel");<br />
FreeLibrary(hinstLib);<br />
But when I actually go to use the API I get an error at runtime. Is there a problem in my declaration or the dll?
|
|
|
|
|
Assuming you're getting non-NULL return values from LoadLibrary() and GetProcAddress(), I'd say
the problem is in calling FreeLibrary(). Don't you want to keep the DLL loaded?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
This episode brought to you by the letter Z
|
|
|
|
|
Download a tool called "Dependency Walker". If you don't have a .def file being used by the linker, you'll see underscores '_' preceding each exported function name. To fix this, add a .def file to your project and then modify the linker properties to use the .def file (Definition file). Edit the .def file to have an EXPORTS section:
EXPORTS
FirstFunctionToExport
SecondFunctionToExport
ThirdFunctionToExport
....
You get the idea.
Also, as already mentioned, don't call FreeLibrary() until you are actually done with the DLL.
If this solves your problem, take some time to try to figure out mine above. I've already dumped a couple hours into it (mostly research - maybe 45 minutes of actual coding).
|
|
|
|
|
How do you declare MGetPixel?
|
|
|
|
|
The DLL is not causing the problem, I believe it is my declaration. The maker of the DLL said to
LINK WITH GETPROCADDRESS
CALL THEM LIKE REGULER WINAPI (same params)
So MGetPixel should have the same parameters as GetPixel.
|
|
|
|
|
Even if the function declaration is correct, it's not going to work if you call
FreeLibrary(hinstLib) after GetProcAddress(...).
Mark
Mark Salsbery
Microsoft MVP - Visual C++
This episode brought to you by the letter Z
|
|
|
|
|
Ok, I found my problem, Im defining my import wrong. I actually read the runtime error and it said I'm defining my function one way and the actual function is defined in a different way. How would I define a GetPixel function. HE said to declare it as any other WINAPI.
|
|
|
|
|
vegito616 wrote: How would I define a GetPixel function. HE said to declare it as any other WINAPI.
What you had was fine for getting a pixel value from a source DC.
Windows APIs use the WINAPI calling convention:
typedef COLORREF WINAPI (*MYPROC)(HDC, int, int);
where WINAPI == __stdcall
Mark
Mark Salsbery
Microsoft MVP - Visual C++
This episode brought to you by the letter Z
|
|
|
|
|
Hello,
Here's my problem:
I have an ActiveX control which has the functionality of a video player. After integrating it in my MFC dialog, when I play the video, if I drag the dialog out from the screen, or maximize it, or drag some other dialog over it, the ActiveX control doesn't redraw its child windows properly.
More exactly, it's about two DirectX child windows which are created for playing the video. One is a DirectX output window and one is the video overlay. Instead redrawing them corectly (video frames playing) I get the area filled with the MFC dialog's background. Setting Clip Siblings to true in the MFC dialog's properties doesn't help much. Indeed, I don't have the area filled with the background but the redraw of the ActiveX windows isn't still made properly (it's a mess .. background mixed with video or something else.. )
I managed to get the handles of the two DirectX windows and tried various solutions starting from calling Invalidate for the entire control to WinAPI calls to RedrawWindow on the handles (and others). Nothing seems to make the video output windows repaint themselves after being covered with something else.
I need to mention that I don't have any experience with DirectX or with ActiveX/COM besides using controls.
If someone can give me a hint for a solution many many thanks in advance.
|
|
|
|
|
Is the ActiveX control written by you?
My first try would be to disable the erase background and paint events in the MFC dialog, and see if the control draws properly... even that your MFC dialog will look horrible. If the problem was that your dialog ruins the video playing, then you can try to set the flag for clip children (not clip siblings).
Can you tell us if the ActiveX control is using DirectX overlay for playing video?
Regards,
|
|
|
|
|
No, the ActiveX isn't written by me.
I have already tried to disable the WM_ERASEBKGND message for the dialog and the only thing changed is indeed that the dialog looks horrible. The ActiveX control has the same problem. Adding the disabling WM_PAINT makes the dialog fully transparent - and still no proper redraw in the video control. (I've let only the control at this moment on the dialog, which is a modeless one launched from the main application dialog)
My mistake, sorry, I wrote the first post in a hurry, the Clip Children was the property I set and doesn't make much difference, not the Clip Siblings.
Finally, yes, the control is using DirectX overlay, is the problem there ?
Thank you for your interest
|
|
|
|