|
Could someone please explain to me how design-time license works. I have been doing a lot of research on the net regarding this, but am not satisfied with what I have found. There is an article on this website that talks about it briefly.
http://www.codeproject.com/useritems/msflexgrid_in_cop_ctrl.asp?target=design%7Ctime%7Cruntime%7Clicense#xx460936xx
Only this article the guy registers a license for his control in the code itself, but where did he get the license key?
I would like to use mschart.ocx, but when I try to instantiate it in the code it says that I require a design-time license. Now currently I have office97 on my machine and so I did not have mschart.ocx. I downloaded it off the net and stuck it my my system32 directory and registered the ocx.
Here is a question, lets say that at somepoint I do get the so called design-time license for mschart.ocx. Will I be able to use it since I am only running office97? or do I require office xp installed on my macine in order to use it?
As you can see there is a lot I don't know. PLease help enlighten me.
Thank you.
Sincerely,
Mardigin
|
|
|
|
|
Oops The link I meant to paste is:
http://www.codeproject.com/useritems/MSFlexGrid_In_Cop_Ctrl.asp
Sorry about that.
Mardigin
|
|
|
|
|
Okay, I used the license key requestor to try and discover the license key for mschart.ocx
This app can be downloaded at http://support.microsoft.com/default.aspx?scid=kb;en-us;Q151771
However it says that mschart.ocx does not have a license.
This is basically what I wish to do. I wish to embed an excel spreadsheet and chart into an application build using MFC. I wish my users to only require office 97 at best installed. Is this a possability? Are there ActiveX controls compatible for excel97 spreadsheet and chart?
Mardigin
|
|
|
|
|
Hi, all
How do you “point” a function pointer to an array of byte code? I have converted a series of assembly instructions to byte codes (I don’t want to use inline assembly), and want my function pointer to point to that array of byte codes. The problem is that the VC++ compiler won’t cast from chars to the defined function pointer. The following code might explain better:
<br />
int (* FuncPtr)(int x, int y);
char ByteCode[] = {...};
<br />
FuncPtr = ByteCode;
The problem is that VC++ won’t covert from char array to the function definition. I tried adding “(void *)” when pointing but it still wouldn’t convert.
|
|
|
|
|
It seems I was logged out when I posted this...
Anyhow can anyone help me
Aidman » over and out
|
|
|
|
|
I have done this in the past and it has worked very well. As previously noted, it is very risky.
In my case, I used this technique to invoke bits of machine code generated at run time by compiling a script language on the fly.
BYTE CodeBuf[] = { ... };
typedef int (*CodeFunc)();
CodeFunc func = (CodeFunc)CodeBuf;
int returnvalue = (*func)( arg1, arg2 );
The Ten Commandments For C Programmers
|
|
|
|
|
Thanks, but why is it risky?
Aidman » over and out
|
|
|
|
|
Anonymous wrote:
The problem is that the VC++ compiler won’t cast from chars to the defined function pointer
I'm not surprised. This is an extremely dangerous thing to do, and should be avoided if at all possible. Is there any reason why you don't want to use inline assembly? You do realise that you can write a function as a separate assembly language file and link it with the rest of the program, don't you?
If you have to do this (and I strongly recommend that you don't), then you have to cast to the exact type.
typedef int (*FUNCPTR)(int, int);
FUNCPTR FuncPtr;
char ByteCode[] = {...};
FuncPtr = (FUNCPTR)ByteCode; although, I'm not sure if the compiler will let you do this. It may simply not want to cast a non-function pointer to a function-pointer, and I don't blame it
Ryan "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"
|
|
|
|
|
Ok thanks
Ryan Binns wrote:
This is an extremely dangerous thing to do, and should be avoided if at all possible
Why is it dangerous and should be avoided? What can go wrong? Becouse the only diffrens I can see is that you have a function in your data memory area instead of the code area.
What else am I missing?
Aidman » over and out
|
|
|
|
|
Aidman wrote:
Why is it dangerous and should be avoided? What can go wrong? Becouse the only diffrens I can see is that you have a function in your data memory area instead of the code area.
What else am I missing?
I think a couple of things were pointed out below. But there are a few problems:
1. The Visual C++ compiler uses certain registers that it expects to be preserved between function calls. If they're not preserved, then errors can be introduced into the program.
2. By default, the data memory area can be read/written, but can not be executed from. You have to change the access permissions of the data area so that it can be executed from. This is done by Windows to prevent malicious programs from compiling code in memory (to bypass virus scanners) and then executing it.
3. If you use the wrong calling convention, the stack can be corrupted and when the function returns, the program may start executing at the wrong place, causing access violations, and possibly crashing the computer.
4. If you accidentally overwrite this array with other data, then the code will obviously become corrupted and will cause problems if you then execute it as a function. The code memory space is protected from this by Windows, again using access permissions (which can be changed, btw).
5. What if somebody hacks your program after it's loaded and changes the data in this array? This is a big security hole. The code memory is protected from writing by Windows (as I said above), but the data memory is not.
Basically, if you know exactly what you're doing, then it's no more dangerous than any other code, as long as you seriously think about what can go wrong. If you're not sure exactly how things are handled, then I'd recommend doing it another way. If it's static code, then either use the inline assembler or a separate assembly language file, and let the compiler sort everything out. If the code is dynamically compiled by your program, then consider compiling it to a DLL and loading it with LoadLibrary() (a bit more difficult, but a lot safer). In general, executing code from data memory is not a good idea because of the security concerns and possibility of data corruption.
Hope this explains things better
Ryan "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"
|
|
|
|
|
typedef int (*tMyFuncPtr)(int x, int y);
tMyFuncPtr Funcptr;
FuncPtr = ByteCode
The warnings:
a) Are you aware of all the performance issues of mixing code and data on todays processors?
b) specify the calling convention in the typedef!
c) not all processor architectures allow execution on tsack or heap
d) don't do that unless you can prove it's worth the trouble
"Der Geist des Kriegers ist erwacht / Ich hab die Macht" StS
sighist | Agile Programming | doxygen
|
|
|
|
|
Ok thanks
peterchen wrote:
a) Are you aware of all the performance issues of mixing code and data on todays processors?
peterchen wrote:
c) not all processor architectures allow execution on tsack or heap
Where can I find the info on performance issues (for mixing code and data) and processor support (for execution on tsack or heap)?
Aidman » over and out
|
|
|
|
|
Aidman wrote:
Where can I find the info on performance issues (for mixing code and data)
unfortunately, I don't know anymore. I just remember an article that discussed that techniques like "compiled bitmaps" (popular with ModeX) aren't worth the trouble anymore.
Most CPU architectures (including Intel) have separate Code and Data Caches. If I recall correctly, the main performance problem ins when there's an overlap, the CPU flushes both Code and Data cache (since they are not meant to overlap). I might be wrong here, though.
Aidman wrote:
and processor support (for execution on tsack or heap)?
Windows allows separate read/write/execute flags to be set for allocated pages (i.e. it could deny the stack exectution rights - zap go all buffer overflow intrusions). It doesn't make use of this on the x86 / Pentium platform; you would have to check the docs of the particular CPU/OS/Compiler combination but it's possible and makes sense.
Peter
"Der Geist des Kriegers ist erwacht / Ich hab die Macht" StS
sighist | Agile Programming | doxygen
|
|
|
|
|
I have a problem with my MDI. I have three views. Two are CHtmlViews and when one of the CHtmlView (View2) is clicked; it is suppose to call the other CHtmlView (View1) to go to that website. I have in the CApp class the global variable theApp and a public class GetHtmlView(). GetHtmlView goes through the active frames until View1 is found and return a pointer to it. The problem that I get is
'CApp::GetHtmlView' : cannot access protected member declared in class 'CApp'
: see declaration of 'CApp::GetHtmlView'
: see declaration of 'CApp'
This is CApp::GetHtmlView declaration
CActWin* GetHtmlView();
This is CApp declaration
public CApp : public CWinApp
I have no protected members inside of CApp.
This is where I get the error inside of View2
CActWin* pActWin1 = theApp.GetHtmlView();
pActWin1->Navigate2(lpszURL,NULL,NULL);
The theApp is global like previously stated
extern CApp theApp;
Off topic, but does anyone know the best solution for when View2 is clicked and I don't want View2 to navigate to that website that was clicked on. I used in the OnBeforeNavigate2(); Navigation("current html", NULL, NULL). I just think there should be a better way to prevent View2 from going to another site.
Thanks for any help
|
|
|
|
|
What value I would get if I send for example WM_USER + 100 to window, that have no handler for it (should it process it to DefWindowProc)?
|
|
|
|
|
If you know that the window definitely does not have a handler for the message, then you will get a value of 0. If you don't know for sure, don't rely on it - windows often post messages to themselves for doing various things, and they can have any value and may not be documented.
Ryan "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"
|
|
|
|
|
There does not seem to be an ActiveX Control for MS Excel from office 97. Is this true? If so is there anyway of writing an app that uses an ActiveX Control for Excel from a later version of office, but that will still be compatible with office 97?
Sincerely,
Mardigin
|
|
|
|
|
Hi,
My program needs to stop a do/while loop when the user decides it. I first use a progress dialog bar which works great but it is not convinient.
I would like to stop a do/while loop using a button of my toolbar.
How can I tell the program to spend sometime checking on the toolbars and menu while it is running within the loop?
Thanks,
RNO
|
|
|
|
|
I use something like this to detect if the user presses a button inside a loop:
MSG msg;
while(PeekMessage(&msg,NULL,0,0,PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
jhaga
---------------------------------
Do not hire a man who does your work for money, but him who does it for love of it.
Go confidently in the direction of your dreams! Live the life you've imagined. As you simplify your life, the laws of the universe will be simpler.
Do not be too moral. You may cheat yourself out of much life. Aim above morality. Be not simply good; be good for something.
-Henry David Thoreau-
|
|
|
|
|
I think the normal thing to be done in this case is running your do/while loop in a separate thread so you can handle all the messages, including toolbar notifications, from the main application thread normally.
Your while loop condition should check on a global variable that is to be changed by the toolbar message to fail the condition.
|
|
|
|
|
Hi there,
I'm writing a serial port class that has its own thread to read data out of the port in the background. That bit all seems to work fine, but I want to get the data from the buffer that I'm storing it in and update a read only text box in a dialogue in my app. Where is the best place to do this should I do something like that in the OnIdle function and just use a pointer to the dialogue to update the variable or is there a better way.
Cheers
Andy
|
|
|
|
|
One solution is messages. Send a message from the worker thread to the main thread, which updates the controls in the dialog box.
Kuphryn
|
|
|
|
|
I want to output this characters which range between 0x0000 and 0xFFFF, but some of them can not output, I don’t know the reason, and how I can know which character can output?
|
|
|
|
|
All characters can be output. It's up to the particular device (e.g., display, printer, file) as to whether it can be rendered or not.
|
|
|
|
|
.. and also remember that if you are 'outputing' your characters via an edit control, ensure that the font being used can render unicode characters. Not all can display the all the character sets.
"..Even my comments have bugs!"
Inspired by Toni78
|
|
|
|