|
I'm frequently asked to reinstall Windows for people who made a mess of their OS. I'm planning to write a program that makes a backup of the drivers, so I don't have to spend a lot of time searching for the drivers.
My first question is: Is this possible? Does all the necessary information get copied when the drivers are installed?
The second question is: Does anyone have any tips or methods how to go about this task? (I have seen the system info project that lists device drivers)
I'm now testing with the overkill method: find all the dll,exe,sys,inf,vxd files (<2MB) on the Windows drive and the files in the 'drivers' folder and make a copy to a CD-Rom. If Windows needs a driver I give the location of the CD ROM. This has limited success.
|
|
|
|
|
if you have to do regular restores, just invest in a mirroring software solution.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
I agree making a mirror of a clean install (when the PC is new) is a good option. But:
1) Mirroring is not an option ones the OS is a mess.
2) In most cases I don't have the option to make a mirror before the problem(s) occured.
3) I want to make this program as a hobby-project.
|
|
|
|
|
Hello gurus,
Can someone remind me how to allocate a dynamic 2D array of int in standard C with malloc and free???
Thanks in advance.
Best regards.
Fred.
There is no spoon.
|
|
|
|
|
You could do it like this:
int* pInts = (int*)malloc(width*height*sizof(int));
int MyInt = *(pInts+x+y*width);
Steve
|
|
|
|
|
Hi steve,
Thanks for your reply.
Actually I am targetting the algorithm with the loops and use it as a normal array.
<br />
int** myArray=NULL;<br />
<br />
int** AllocateArray(int nHeight, int nWidth)<br />
{<br />
int** newArray=NULL;<br />
int i, j;<br />
<br />
for (i=0; i < nHeight; i++)<br />
....
<br />
return newArray;<br />
}<br />
<br />
void FreeArray(int*** array)<br />
{<br />
}<br />
<br />
int** myArray=AllocateArray(32, 32);<br />
<br />
myArray[i][j]<br />
<br />
FreeArray(&myArray);<br />
I don't remember the rest of the code.... that's the purpose of this topic
Thanks for helping me.
Fred.
There is no spoon.
-- modified at 8:55 Saturday 25th February, 2006
|
|
|
|
|
ok, I have found back the algorithms
Thanks for the help
Best regards.
Fred.
There is no spoon.
|
|
|
|
|
See here. You'll need to substitute malloc() and free() accordingly.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
ok, I have found back the algorithms
Thanks for the help
Best regards.
Fred.
There is no spoon.
|
|
|
|
|
|
The answer to this question is simple: You can't get the information. C++ is a statically typed language - When you cast a pointer to a void* you are throwing away this type information.
Steve
|
|
|
|
|
Modified
Thank you.
So I don't know enough information a bout casting.
But, if we write a function that does this casting, like below:
struct x st;
read ((void*)&st);
st.a=5;
Forgetting this cast, is there any way to find and get these information (you called type information)from compiler any where in our code?
Thanks alot in advanced
//This is not a signature
while (I'm_alive) {
printf("I Love Programming");
}
-- modified at 6:58 Saturday 25th February, 2006
|
|
|
|
|
The general pattern to this kind of stuff is this:
read((void*)&st);
void read(void* pData)
{
x* pX = (x*)pData;
}
Naturally if we have code like this we're in real trouble:
int data;
read((void*)&data);
The reason we get in trouble is that, since we throw away the type information with the void* cast we're forced to cast back in the read function and the compiler has no way of checking the validity of the cast. In general casts represent a design flaw, which is one of the reasons why C++ introduced the static_cast , const_cast and reinterpret_cast keywords - casts are ugly and so should look ugly and be easy to find. There are times when casting is necessary but this should only be at the low-level portions of an application and the actual casts should be hidden behind type safe interfaces.
Steve
|
|
|
|
|
Thanks alot for your nice information about casting.
I used some sort of it, but never tried(did not needed yet) reinterpret_cast.
any way, one problem is casting, which disturbs information about a pointer.
I learned it, thank you.
What I am looking for now, is that without casting, is there any way to find some information about a structure? how can we get it from compiler?(I modified my reply.)
Thank you ver much indeed.
//This is not a signature
while (I'm_alive) {
printf("I Love Programming");
}
|
|
|
|
|
There is no general way to do this. While in some cases possible, by examining debug information for example, it is not possible in all cases and isn't efficient. It's not really in the spirit of the language, which is based on static typing. Perhaps if you describe the specific problem your trying to solve I (or someone else) can be of more help.
In C++ casting to void* like this:
(void*)p
Is an outdated (because it isn't explicit) way of doing this:
reinterpret_cast<void*>(p)
Steve
|
|
|
|
|
You don't want to say I'm outdated, do you?!!
Thanks.
what I want to do is to write a class, that needs to save it's input to a file, without a need to know what is the type, AND, the information be changable to modify the file by hand.and also loadable later on.
( I wanted to write a setting class, with these 2 function:
mySetting.Save((void*)settings);
mySetting.Load((void*)settings)
)
(I'm not going to save binary info to file, and read it again, I know this is easy!)
//This is not a signature
while (I'm_alive) {
printf("I Love Programming");
}
|
|
|
|
|
If I understand you correctly you want to load or save any type with calls such as this:
int Type1;
double Type2;
MyStruct Type3;
mySettings.Save(Type1);
mySettings.Save(Type2);
mySettings.Save(Type3);
mySettings.Load(Type1);
mySettings.Load(Type2);
mySettings.Load(Type3);
In C++ you could do this with template functions:
class CSettings
{
public;
template<class T> void Save(T& SaveMe)
{
SaveTheData(reinterpret_cast<void*>(&SaveMe), sizeof(SaveMe));
}
template<class T> void Load(T& LoadMe)
{
LoadTheData(reinterpret_cast<void*>(&LoadMe), sizeof(LoadMe));
}
};
Steve
|
|
|
|
|
I know templates abit, but problem is not to send different type of data to a class, or function.
It's to save a data structure elements, while we don't know it's elements type or their size. so problem is to find the data type encapsulated in a structure.
anyway thank you very much for your contribution.
//This is not a signature
while (I'm_alive) {
printf("I Love Programming");
}
|
|
|
|
|
I've heard something of RTTI (run time type information), and just this word!
If this is the soloution, I wanted to see how can we enable it in our compiler, and how can we use it?
//This is not a signature
while (I'm_alive) {
printf("I Love Programming");
}
-- modified at 7:11 Saturday 25th February, 2006
|
|
|
|
|
RTTI only works on polymorphic types (types with virtual functions). It doesn't give layout information.
Steve
|
|
|
|
|
So, it seems that I should forget getting such information!,hoping "C/C++" designers think about this issue on later standards!! (If they think about it's usage, it's great usage to create independent classes or functions)
Thnk's alot to all the guys helping me, out there.
Thank you very much indeed for your time and attention
//This is not a signature
while (I'm_alive) {
printf("I Love Programming");
}
|
|
|
|
|
Hamed Mosavi wrote: So, it seems that I should forget getting such information!,hoping "C/C++" designers think about this issue on later standards!! (If they think about it's usage, it's great usage to create independent classes or functions)
just don't try to solve you problem of design with another problem of design... if cant do the job with C/C++, it is simply because you haven't oriented you program for that language...
sorry, it's not an issue to consider in further standards, C/C++ are simply not java/C#...
TOXCCT >>> GEII power [toxcct][VisualCalc 2.24][3.0 soon...]
|
|
|
|
|
Hi,
I've not been working with java or C#.
I just wanted to ask you, Do these languages solve these type of problems?
Furthermore, why giving information about a data type at compile time is not suitable for C/C++ ? I expect an object oriented programming language to give me the ability to write independent classes, is it too much?
(I accept the fact that it is not good for C/C++ to give me these infomation at runtime, you are absolutely right .)
Thank you for your great kindness . You pay the most attention. Excuse me if my english is bad .
//This is not a signature
while (I'm_alive) {
printf("I Love Programming");
}
|
|
|
|
|
Hi,
to answer your question, both languages have a mechanism to do wath you wanted.
In C# its called reflection. You can ask a type(class) which members it has at runtime.
Hamed Mosavi wrote: Furthermore, why giving information about a data type at compile time is not suitable for C/C++ ?
C++ doesn't have this for a few good reassons.
a. Its slow
b. It use more memory
c. hence there is no simple memory to a plain 'c' structure translation
Altough c++ doensn't have this. You can create it if you really need/want to.
But there is another approach you might consider. I guess you want to save data from
the memory to a file or vice versa. This is called persistence, or like MFC calls it
Serialisation. This method allows just the thing you want.
You can use there framework (CFile, CArcive) to implement the serialisation you need.
Or you can create your own using this concept. It differs from you concept to a more
OO solutiuon.
Your solution needed one class who knows everything about all classes (this is alsoo
nessecary in c#). When adding a new class you never know if there are restriction on
what to save to file (for instance, void pointer list, function pointers, temporary members)
In the more OO solution, everey class knows how to save/load itself too an archive or
other class object that handles binary data to be saved or loaded to file and memory.
In the second solution, when adding a new class you only need to implement the
save/load function for that class and everything works without problems.
codito ergo sum
|
|
|
|
|
Thank you very much.
Finally one programmer, just get what I needed. Thank you very much.
It's really kind of you. (If you want the fact, I always use CStdioFile, but never used serialization already). However I'm still not sure about the fact that can I bring back my data from a file to a structure with an unknown data elements, and beside the file tobe a text not a binary, but your solutions and information about C# were elegant. Thank you again and again.
I will check to find the best design, If I get a good approach, I'll put this class here in CP.
Thank you.
//This is not a signature
while (I'm_alive) {
printf("I Love Programming");
}
|
|
|
|