Does anyone know of an Assembler function that works kind of like Kernel32.dll's Beep() function? (The NT-family version, please. ) I want it to be an easy-to-use function which I can embed into C, because I don't feel ready to mess with the Assembly yet... Anyone know? Thanks!
Hi there, I'm trying to write a program that takes another precompiled project (was doing this in GCC but now trying in Visual Studio, bit of a jump I know....) and executes the code in it. I know this sounds like using a standard DLL but here's the bit that's got me stumped.
The precompiled project (written in C) is made up of a bunch of functions (called from the main program) but these functions call functions in the main program. I can get the first part working but I can't figure out how to make the DLL use some of the main functions. Any books I have and any internet info I've found only seem to cover the first part but not the second.
As shown in the title this is for an emulator type program.
If someone could at the very least tell what doing this is called, it would help immensely! Please ask if I need to explain more.
Probably the easiest way would be to pass function pointers to the DLL which it would use to callback into the .EXE. Here's the basic idea:
// In the header file of the DLL. Included by both DLL and EXE.<br />
typedef void (*PMainFunc)() PMain;<br />
extern"C"void SetCallback(PMainFunc pCallback);<br />
// In the exe.<br />void InMainCalledFromDll()<br />
// Blah....<br />
int main(int argc, char* argv)<br />
There are many variation of this theme, for example passing the address of a structure of function pointers or using virtual functions. This should get you started.
It sounds like you have a circular dependency, where your library expects the program using it to have functions with specific names. This is a questionable design, but legal as long as it's a static-link library, not a DLL.
A better design is to have the app pass a pointer to a callback function, which the library code calls as needed.
Thanks for the replies. Yeah I realise the overall design is questionable but it's basically necessary, the program is to employ C code that's been written for a Microchip device and emulate the already written OS it runs on top of. The idea being I can write and test code without having to build the actual device that uses it straight away.
I am new to c++,VC++. I am working on a project where i difference two files.
I am passing in the Header Names as commandline arguments in the following format.
cat,dog and pig is ok. But "don key is not getting recognised.It is read as just "don". I should be able to read it as "don key" or i might replace the white space with something else.
I was wondering if anyone knew of a way, if it is even possible, to declare a macro with a variable parameter list. Say I have a function with a long name, in a class with a long name, in a namespace with a long name and I want to remame it with a short name
Unfortunately, you can't use variable length argument lists with macros. You can sort of fudge it by surrounding the arguments with parentheses, but then you end up with parentheses in the expansion, so it's only useful if the parentheses are legal when expanded.
"Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late"John Nichol "Point Of Impact"
I have a static control(derived from CStatic) and it contains two lines. I want to set the color of the first line to blue and the second line to red. Currently I am using the CDialog::OnCtlColor and using the SetTextColor function to set the color. However it sets the color for the whole static control i.e. both the lines. Can someone help?
The OnCtlColor message doesn't give you that amount of control over the text lines that gets coloured.
In cases like that where you need very flexable colour control, you might as well use the rich edit control, or search for one the various HTML-CStatic hybrids that are available on this site.
And got this in output:
'auxa.txt' is valid.
'aux.txt' is valid.
'aux .txt' is valid.
'C:\filename.txt ' is valid.
'C:\auxa.txt' is valid.
'C:\aux.txt' is NOT valid.
'C:\aux .txt' is NOT valid.
Seems to work only for fully qualifed paths. Seems to fail the trailing space rule in any case.
I don't know if i'm on the right forum but for god sake help. PLEASE.
i'm on windows xp home edition and every time i try to open my documents or my folders the page comes up in blocks and then microsoft sends a message saying it must close the program, i check the error report then it comes up Dr Watson postmorton debugger,then closes. Help i've run 3 different anti-virus scans and only one showed an error (??chost) but cause it came up as an error it carn't delete it. please if anyone can help remove the virus or what ever the prob is can you site it.
please tell me what it is and how to remove it cause i really need to gain access to my files . thanks