|
if(AfxMessageBox (_T("Question"),MB_YESNO)==IDYES)<br />
{<br />
}<br />
else<br />
{<br />
}
|
|
|
|
|
Hi,
Does anyone know of a free tool I can use to convert a binary data file into an array of literal hex values, so as to be able to embed the data of the file in my source code?
Joel Holdsworth
|
|
|
|
|
You'd be better off adding the binary data to the EXE as a resource and using the FindResource , LoadResource and LockResource functions to access it in place.
Steve
|
|
|
|
|
True enough... when you're windows programming, not working on an embedded system!
Joel Holdsworth
|
|
|
|
|
So you're not targeting Windows? If this is the case it would have been a good idea to mention this as this is a Windows programming site and unless otherwise informed people will assume you're programming for Windows.
If you're targeting Windows there will little difference. The data is the same size regardless. If you turn it into hex literals the compiler turns it back into raw data when it compiles it. If you attach it as a resource the actual raw data is in the EXE instead if the same data reconstructed by the compiler.
If you're not programming Windows your toolset and platform may well provide a similar feature.
Steve
|
|
|
|
|
Just write your own using base64 encoding and something like this[^]
led mike
|
|
|
|
|
int c, x=0; while((c=getchar())!=EOF){if(x++==8)x=0,putchar('\n'); printf("\x%02X, ",c);}
Run it with: "appname < datafile.bin > codefile.cpp" It's C but I wrote it like it was Perl
|
|
|
|
|
Hi,
I need to write a MFC application that views MSOffice documents. I would like to know if some of you have already done some thing like this and what would be the best way to accomplish it.
I've found some companies selling OCX components to do that. Does anyone tryed those components? Did you like them? What component would you recommend me?
Thanks in advance,
Vinicius
|
|
|
|
|
You have to search for automation. For example Word automation or Excell automation. You should be able to find a lot of resources about that with google. This website has also some resources about automation.
|
|
|
|
|
What MSOffice documents in particular are you wanting to read? You can use automation to do most tasks, but you would always need the relevent MS program to be installed on the machine. Ie. if you want to read .xls file, you will need to have MS Excel installed.
You could however attempt to read the file directly, for this you would need to know exactly how the file is structured. Try searching for "Compound document" along with the filetype.
|
|
|
|
|
Basically, I intend to read Word and Excel documents and I believe that in most cases I will have MSOffice installed on the machine.
Vinicius
|
|
|
|
|
waldermort wrote: You can use automation to do most tasks, but you would always need the relevent MS program to be installed on the mach
I am not sure but I don't think this is true. You can simply provide a dll with your program and register it. But I don't remember which one.
|
|
|
|
|
|
Hi all,
How can I retieve the value of a registry entry? I have tried this:
<br />
res = RegOpenKeyEx(<br />
HKEY_CURRENT_USER,<br />
TEXT("My value"),<br />
0,<br />
0,<br />
phkResult<br />
)<br />
But the program bomb out....
Many thanx for any help.
Regards
Programm3r
|
|
|
|
|
did you see previous links. and this function opens specified key
|
|
|
|
|
Programm3r wrote: But the program bomb out....
What does 'bomb out' means ? Please be explicit when you encounter a problem. Is it a compilation error, an exception that is raised (which one in this case, ...).
If it's a crash, did you use your debugger to see what's happening.
I think the problem comes from phkResult. What is its value ? Did you initialise the pointer ? If not, it will contain an invalid address and the function will try to write there and crash your program.
Post some more relevant code (so when the other variables are initialised also)
|
|
|
|
|
My bad ... Let me explain, "bombs out" means that the program raised an exception that was caught by one of the Windows exceptions, and caused the famous "Send / Don't Send" dialog to pop-up.
But i do think you are right about the "phkResult" variable..., but the question remains how does one get the value of a registry entry?
Thanx for the response.
Regards
Programm3r
|
|
|
|
|
|
Thanx i'll try it...
Regards
Programm3r
|
|
|
|
|
Mention KEY_READ as fourth parameter. And how phkResult is initialized.
|
|
|
|
|
Thanx for the response, I thought phkResult was receiving a value ... thus I declared it as: PHKEY phkResult; but, this might the problem right?
Regards
Programm3r
|
|
|
|
|
Better declare it as HKEY hkResult; and pass its address as parameter.
|
|
|
|
|
Thanx I'll try it...
Regards
Programm3r
|
|
|
|
|
Programm3r wrote: but, this might the problem right?
Yes this is the problem. Better do that this way:
HKEY hkResult;
And pass the address of the key to your function (&hkResult)
|
|
|
|
|
Try something like this (I haven't tested this):
-----
// Open the key.
HKEY hKey;
LONG res = RegOpenKeyEx(
HKEY_CURRENT_USER,
_T("Software\\My Company\\My Product"),
0,
KEY_READ,
&hKey
);
if (res==ERROR_SUCCESS)
{
// Now read a value in the key we opened.
DWORD Value; // Value to read.
DWORD Type;
res = RegQueryValueEx(
hKey,
_T("My value"),
NULL,
&Type,
reinterpret_cast<const BYTE*>(&Value),
sizeof(Value)
);
if (res==ERROR_SUCCESS)
{
if (Type==REG_DWORD)
{
// Access data in 'Value'.
}
}
// Close the key.
RegCloseKey(hKey);
}
Steve
|
|
|
|