|
Hmm...I think you may be a bit confused on how to program with COM ojbects and how they're used at run-time.
#import is used only at compile time to include declarations of objects supported by the COM DLL. The path is only relevant on the computer where your code is being compiled. This is very similar to #include.
At install time, you must register any COM components that you install. This adds entries to the registry that the COM APIs use to find the DLLs and create the proper execution environment for the components. Most COM DLLs export a function called DllRegisterServer which the DLL author must provide to perform the necessary registration steps. Most installer packages (InstallShield, Wise, etc.) will call this function if you specify the DLL as requiring registration. You can also register a component using the regsvr32.exe utility, which calls DllRegisterServer .
So, the path to the DLL is established at registration time and stored in the registry. You can install the DLL anywhere.
At run time, you instantiate an instance of a coclass by specifying either a CLSID or PROGID. The COM API CoCreateInstance (which is either called by the smart pointer, or by your code directly, depending on how you've written things), performs a lookup in the registry to find the location of the DLL.
A warning about installing MSXML yourself. With later versions of the parser, there are more than one DLL. I'm not sure about V1.0. You are probably better off finding out what installation method Microsoft recommendeds. They probably have an installation package that you can re-distribute. That installer will install all required components and perform the necessary registration.
Secondly, V1.0 is very old. Newer versions support more of the XML and related standards.
Finally, depending on what OS you're targetting, a version of the parser may already be installed.
HTH
Brad
|
|
|
|
|
Thanks for your help mate.
Cheers
|
|
|
|
|
i tried to register a .dll and i got the the following error :
Debug Assertion Failed!
Program:......REGSVR32.EXE
File: OLEFACT.CPP
Line: 122
can anybody help me out of what is the problem
pavan
|
|
|
|
|
Debug assertions typically aren't compiled into release code, so this likely is in the DLL rather than regsvr32.exe. As well, olefact.cpp is an MFC file, so likely not part of regsvr32.exe.
Try running the whole thing under the debugger so that you can break when the assertion trips and look at the call stack.
Brad
|
|
|
|
|
i know i can use ran function to generate a random number in VBScript.
for example:
/*
dim char_array(35)
char_array(0) = "0"
char_array(1) = "1"
char_array(2) = "2"
char_array(3) = "3"
char_array(4) = "4"
char_array(5) = "5"
char_array(6) = "6"
char_array(7) = "7"
char_array(8) = "8"
char_array(9) = "9"
randomize
do while len(output) < 6
num = char_array(Int(9 * Rnd + 0))
output = output + num
loop
*/
How can i get a random number in MFC?
Habbit--Beginner In MFC
|
|
|
|
|
void srand( unsigned int seed );
and to get the random number
int rand( void );
See the MSDn for more info
It is amazing what you can accomplish if you do not care who gets the credit. - Harry S Truman
|
|
|
|
|
if i limit the range of generated number from 1 to 35,how can i do?
Habbit--Beginner In MFC
|
|
|
|
|
A simple way would be to alter the output
nRand = rand() % 36;<br />
nRand = nRand == 0 ? 1 : nRand;
It is amazing what you can accomplish if you do not care who gets the credit. - Harry S Truman
|
|
|
|
|
easier will be
nRand=1+rand()%35
|
|
|
|
|
Yes I agree that is better, I just wanted to show an easy to understand method, plus I was still asleep!
It is amazing what you can accomplish if you do not care who gets the credit. - Harry S Truman
|
|
|
|
|
And your distribution curve is wrong. Twice as much chance of getting a 1.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Tim Smith wrote:
Twice as much chance of getting a 1.
Twice as much as what, not getting a one? How so?
|
|
|
|
|
My code was nRand = rand() % 36; which gives a "random" number in the range 0 - 35 inclusive, I added 1 if the "random" number was 0.
Therefore the value 1 is returned for rand() values of 0 and 1, sort of twice as much chance of 1 being returned
It is amazing what you can accomplish if you do not care who gets the credit. - Harry S Truman
|
|
|
|
|
Ahh, gotcha! I'm so used to seeing it in x = (rand() % 36) + 1; form that anything else looks odd.
|
|
|
|
|
Yes I did appreciate that, but rand() does repeat it's "random" numbers after only a few thousand iterations anyway. Which is why it is not of much use when a real random number is required any way, like I said I was still asleep!
It is amazing what you can accomplish if you do not care who gets the credit. - Harry S Truman
|
|
|
|
|
Ted Ferenc wrote:
...when a real random number is required...
Which we know cannot be produced on a computer!
|
|
|
|
|
the Q is from java.
java's jdb.exe uses shared memory with an user's name (i.e. my_memory), now i want to access this memory in C++.
where is start point? any comments?
thx
includeh10
|
|
|
|
|
You will have to use JNI calls for doing this.
I had a similar problem, and I made the java pgm create a piece of shared memory, and from C++ I used shmget function to access it. But shmget failed from either side ( depending on which one creates the shared mem ).
Anyway you can start exploring with "JNI" calls.
You may find this piece of code useful.
JNIEXPORT jint JNICALL Java_posix_SharedMem_shmget
(JNIEnv *, jclass, jint key, jint size, jint flag) {
return shmget(key,size,flag);
}
"A robust program is resistant to errors -- it either works correctly, or it does not work at all; whereas a fault tolerant program must actually recover from errors."
|
|
|
|
|
i never use jni before, i only tried pipe but it doesn't work.
could u send real code to my email?
thx
includeh10
|
|
|
|
|
Hi. I have a program that allows a user to select a file and the user presses the Ok button, the program will write out an exe and store or copy the file together with the newly created exe. When the user runs the newly created exe, it will run the file when it presses a button on the exe.
I managed to create the exe already. I now need to solve the storing problem. I tried using the zip and unzip method, but it only unzip it to another folder and not excute it. So how can I go about doing this?
|
|
|
|
|
possible u can store it in "resource" part of an exe.
see how to modify resource of an exe in vc help.
includeh10
|
|
|
|
|
I understand what you mean. But my file might keep on changing. So how can I update the resource for the file in the first place?
|
|
|
|
|
You can use the concept of Self Extractors
See this url :
http://www.codeproject.com/file/self_extractor.asp
"A robust program is resistant to errors -- it either works correctly, or it does not work at all; whereas a fault tolerant program must actually recover from errors."
|
|
|
|
|
I'm writing an SDI application and I cannot get the name of the app that appears in the list box on the system toolbar to change (in winxp when you open the same app many times , he groups all of them on one button with a list box, and the text that is written on it is TODO: <File Description> . I have looked at the document, view, app, and frame titles but none of them change it. The only place that i found this string, was in the resources (versioning), but if i change that, nothing happens .
For projects that are imported from vc6 it writes the name of the app that you gave when you have created the project, but I don't know from where to change it, i did a search and replaced it everywhere where it appears but it doesn't change the text that appears on that button. do you have the same problem, or just i have it ?
If anyone knows how to fix this using VC7 I would greatly appreciate it.
|
|
|
|
|
Hi,
Im trying to create a self extracting file. I have managed to do it for my home computer by getting the program to open a file pointer to its own exe file, but when i do this on other computers, I get a sharing violation. Is there a way around this?
Cheers
|
|
|
|