|
You're right, it's not difficult.
mycontrol->ShowWindow( SW_HIDE );
--Mike--
http://home.inreach.com/mdunn/
"That probably would've sounded more commanding if I wasn't wearing my yummy sushi pajamas."
--Buffy
|
|
|
|
|
|
Does anyone know if it's possible to roll my own CA and PKI for NT Workstation Security. For various reasons, I want to be able to work with signed code and SSL connections in a peer-to-peer NT Workgroup (no servers, just four workstations). I can't set up the personal web server (IIS 4.0 personal web server from the NT Option Pack) to handle https and SSL without a Verisign certificate so I would like to create and install my own CA certificate as a root trusted authority in the Trusted Computing Base.
Here's the problem: A University network allows potentially hostile users access to the local network. I want to set up four workstations as a VPN or something similar, but don't have the budget to sacrifice one computer as a server and create a domain. Thus, I would like to secure communications among the workgroup as much as possible. At the minimal level, I would like to get the computers talking to one another using https rather than http, but can't do this without spending a large fraction of my computing budget on Verisign keys.
I haven't seen anything about this anywhere in MSDN or in the magazines. Does anyone know if it's possible? If it is possible, where should I look to learn more?
He was allying himself to science, for what was science but the absence of prejudice backed by the presence of money? --- Henry James, The Golden Bowl
|
|
|
|
|
How do I get the decimal eqivalennt of a 2's complement hex number in VC++ 6.0? In other words, how can I convert FD to a -2 given that FD is a 2's compliment hex number?
Regards,
Mike Zolna
|
|
|
|
|
I'm not sure exactly what you need. A number is a number, no matter how it's stored or what base (decimal/hex) you represent it in. But if you want to go from the number 0xFD to the string "-3" (0xFD is -3, not -2) then just sprintf() it:
char szNum[16];
signed char num = (signed char) 0xFD;
sprintf( szNum, "%d", (int) num ); // cast sign-extends 0xFD to 0xFFFFFFFD
You need to use the "%d" format since that prints the value of a number. The (int) cast puts the correct number of bytes (int-sized, instead of char-sized) on the stack.
--Mike--
http://home.inreach.com/mdunn/
"That probably would've sounded more commanding if I wasn't wearing my yummy sushi pajamas."
--Buffy
|
|
|
|
|
I'm assuming you have FD as text, and need to convert it. I don't think there's a built in way to do this. Some searching reveals a couple of 'hex string to value' conversion routines, one in SNA. Found HEX2INT.PRG in the docs for FoxPro 2.5 for DOS... hmmm...
Oh well, never pass up a chance to fill up a message with a nice pale orange block...
#include <iostream>
using namespace std;
long Hex2Int(char * pszHex) {
static unsigned char byteLookup[22][2] =
{ '0', 0, '1', 1, '2', 2, '3', 3, '4', 4, '5', 5, '6', 6, '7', 7,
'8', 8, '9', 9, 'A', 10,'B', 11,'C', 12,'D', 13,'E', 14,'F', 15,
'a', 10,'b', 11,'c', 12,'d', 13,'e', 14,'f', 15
};
register long total = 0;
int nPosition = 0;
if(*pszHex) {
register int len = strlen(pszHex) - 1;
while (len >= 0) {
bool bFound = false;
int i;
for (i = 0; i < sizeof(byteLookup)/2; ++i) {
if(byteLookup[i][0] == *(pszHex+len)) {
++bFound;
break;
}
}
if(!bFound) throw "Invalid hex number\n";
if(nPosition == 0) {
total = byteLookup[i][1];
}
else {
total += byteLookup[i][1] << (4 * nPosition);
}
--len;
++nPosition;
if (nPosition > 8) throw "Too many hex digits\n";
}
}
else {
throw "Empty string\n";
}
return total;
}
int main(int argc, char* argv[])
{
char s[255];
long result = -1;
while (result) {
cout << endl << "Enter a hex number please, or 0 to exit: ";
cin >> s;
try {
result = Hex2Int(s);
cout << endl << "Hex2Int returned " << dec << result << " [" << hex << result << "]" << endl;
}
catch (char * e) {
cout << e;
}
}
return 0;
}
Note that there's room for optimization here, and there's the issue (see comments) of sign extension. This Hex2Int returns 253 for FD, -3 for FFFFFFFD. But I think you need something like this to do the translation.
|
|
|
|
|
Hey Everybody,
I'm looking for a GZIP file compression library/api or something. I'm writing a vrml file export utility, and since the generated *.wrl files are inherently large, being text files, I'd like to export them in *.wrz format which requires gzip compression.
Anyone have any suggestions on gzipping a file programmatically?
Thanks,
Josh
josh@schroff.com
|
|
|
|
|
Get zlib. This is the canonical library for zipping and unzipping content. You can also look right here on CodeProject at SawZip, Zip and Unzip the MFC Way, and Self-Extracting File Framework.
He was allying himself to science, for what was science but the absence of prejudice backed by the presence of money? --- Henry James, The Golden Bowl
|
|
|
|
|
Ok, with a bit research in MSDN and in the header files, I menaged to collect the following information:
The following code should do easy and fast transparent Blt'ing... BUT as my driver doesn't support (pDC->GetDeviceCaps(CAPS1) & C1_TRANSPARENT) or as there is something wrong with this code, I cannot be sure if it works...
#ifndef C1_TRANSPARENT
#define C1_TRANSPARENT 0x0001
#endif
#ifndef CAPS1
#define CAPS1 94
#endif
#ifndef NEWTRANSPARENT
#define NEWTRANSPARENT 3
#endif
int nSave = pDC->SaveDC();
if(pDC->GetDeviceCaps(CAPS1) & C1_TRANSPARENT)
{
pDC->SetBkMode(NEWTRANSPARENT);
pDC->SetBkColor(crTrans);
pDC->BitBlt(rcDest.left, rcDest.top, rcDest.Width(),
rcDest.Height(), &imageDC, 0, 0, SRCCOPY);
} else
{
}
pDC->RestoreDC(nSave);
This feature is very well undocumented in MSDN, and C1_TRANSPARENT and CAPS1 isn't even defined in the standard headers!!
Any suggestions??
Enjoy, Marc
|
|
|
|
|
Do not use it.
It may be defined during Windows 3.1 time, but I donot know any driver which supports it.
|
|
|
|
|
I have raw serial data being displayed to the screen in ASCII format. I need this data in HEX format, but am not familiar enough with C++ to accomplish this. Here is the code that outputs to window and file in ASCII:
{
for (i=0; i
|
|
|
|
|
Here's some thoughts - you might be able to tinker with one of these. Basically, an intermediate step is involved to take the char and format it as hex.
#include "windows.h"
#include <iostream.h>
#include <strstrea.h>
#include <stdio.h>
void OutHex(char c) {
char buf[8];
sprintf(buf,"%X ", c);
cout << buf;
}
int main(int argc, char* argv[])
{
char test[] = "Here's some char data";
HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
strstream ss;
DWORD dwBytesWritten;
char *p;
cout << "Method 1:" << endl;
for ( p = test; *p; ++p) {
cout << hex << (int)*p << " ";
}
cout << endl << "Method 2:" << endl;
for ( p = test; *p; ++p) {
ss << hex << (int)*p << " ";
}
WriteConsole(hStdOut, ss.str(), ss.pcount(), &dwBytesWritten, NULL);
cout << endl << "Method 3:" << endl;
for ( p = test; *p; ++p ) {
OutHex(*p);
}
int x;
cin >> x;
return 0;
}
|
|
|
|
|
I need my application to get notified when teh file opened in it is modifed outside its editor and give user the option to reload it from disk
like Visual C editor do
Regards
Ali
|
|
|
|
|
I am trying to write a control application for the Windows Media Encoder using the Microsoft supplied Media Format SDK and Media Encoder SDK. I must use the WAVEFORMATEX structure in order to properly set the audio streaming configuration. In the two SDKs as well as the DirectX 8.0 SDK and MSDN it states formulas to calculate the nBlockAlign and nAvgBytesPerSec. Does anyone know if these formulas are correct? I looked at data used by already existent stream configurations and the values given do not match the values gotten when using these formulas. Any help?
Roger Printy
Software Engineer
TeraNex
Orlando, FL
|
|
|
|
|
Does anybody here use the FormatMessage function? I copied the code described in MSDN but the function returns an invalid buffer when I try to show messages over 3006.
...
LPVOID lpMsgBuf;
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(), // works great for messages within 0-3006.
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPTSTR) &lpMsgBuf,
0,
NULL
);
// Display the string.
MessageBox( NULL, (LPCTSTR)lpMsgBuf, "Error", MB_OK | MB_ICONINFORMATION );
...
Could anybody help me?
|
|
|
|
|
Hi,
I use this custom function and it work :
/**=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=\
| ShowErrorMessage : Affiche le message d'erreur correpondant au numéro d'erreur
| que retourne la fonction GestLastError() |
| --------------------------------------------------------------------------------------
|Arguments : dwMessageId -> Numéro d'erreur retourné par GetLastError()|
| Titre -> Titre de la boîte de message (facultatif)
|
|Si le numéro d'erreur est 0 ( i.e ERROR_SUCCESS ), la fonction n'affiche pas le message
|-----------------------------------------------------------------------------------------|
|EXEMPLES D'UTILISATION :
|------------------------
| 1) ShowErrorMessage(GetLastError());
|
| 2) DWORD NumErreur;
| NumErreur=GetLastError();
| ShowErrorMessage(NumErreur);
=**=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=**/
void ShowErrorMessage(DWORD dwMessageId, char* Titre)
{
if (dwMessageId==ERROR_SUCCESS) return;
LPVOID lpMsgBuf;
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
dwMessageId,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPTSTR) &lpMsgBuf,
0,
NULL
);
// Affiche la chaîne.
MessageBox( NULL, (LPCTSTR)lpMsgBuf,Titre, MB_OK | MB_ICONINFORMATION );
// Libère le buffer.
LocalFree( lpMsgBuf );
}
|
|
|
|
|
Hi!
Thanks for the help!
I made more tests with Windows NT and it works (shows messages above 3006). But, it still does not work on Win95/98.
Anyway, thank you.
|
|
|
|
|
Hi,
I want to get programmaticaly the default domain name. instead to use API function, i retrive this information from windows registry
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon]
"CachePrimaryDomain"="SRV_DEV"
If this method is'nt correct, anybody can help me how to get this name using API Function?
I work with Visual C++ 6.0 Windows NT4
Thanks in advance
|
|
|
|
|
I have have been asked to display some data within Excel and display a chart within Excel. Using knowledge base articles I have managed this. BUT.... to display everything, Excel is executed as a separate app. Anyone know how I can insert Excel into a dialog based app, as if it were a control like CWebBrowser2??
I know I can display Excel files inside a CWebBrowser control, however I would rather not have to load Excel, write to it, save the data to an .XLS file, close Excel, and then display the .XLS file....
Any help will be greatly appreciated.
|
|
|
|
|
I am trying to put together a set of classes where I can include my main class ( CGPlayer ) and then through it add sound tracks to play through DirectSound. It all works great for waves, but I used the mp3 playing code in the skinnable app project on this site, and because it uses global functions and variables, when I go to play a second mp3, the whole thing barfs. It looks to me like a lot of work to change it, probably resulting in a design that is flawed due to the diffences between the original design intention, and what I want.
Basically I need to be able to create multiple instances of the mp3 playing class, which all have their own buffer, all attached to my main direct sound interface. As always, any help/suggestions guarenteed to result in good karma for all concerned...
Christian
The content of this post is not necessarily the opinion of my yadda yadda yadda.
To understand recursion, we must first understand recursion.
|
|
|
|
|
I believe Windows Media Player will do that via COM.
|
|
|
|
|
I know I can use it to play files ( in fact I have done so ), but I want to be able to play multiple files at once, modify properties of the playback, and attach the files to points in 3D space, all of which is easy to achieve using DirectSound, and I doubt that Media Player will give me that level of control. Am I wrong ?
Christian
The content of this post is not necessarily the opinion of my yadda yadda yadda.
To understand recursion, we must first understand recursion.
|
|
|
|
|
Well, then, you need only decompress the .mp3's into WAV format. There are lots of Open Source MP3 players, i'm sure they have code that does this.
|
|
|
|
|
Hello,
I am trying to incorporate the use of shortcut keys, such as F2, F3 etc
into my application.
I would like these shortcuts to apply to the parent window (ie, View or
"main" dialog - ie "popup" style, not child) which currently has focus.
I realise that to do so might require having each "Main Window" (the
level at which I want to distinguish for shortcuts) in a seperate thread.
I have tried using RegisterHotKey in a FormView which works OK,
except even if I create a child dialog in a seperate thread,
registering another hot key with the same VK_ gets ignored
(when the dialog has focus) and the View hotkey processed?
I would have hoped being in a seperate thread would render
the hotkey "different" from the other registered in the FormView?
If anyone could tell me where I am going wrong, or can provide any
alternative suggestions, it would be greatly appreciated.
Thanks,
Tanya
|
|
|
|
|
As a former (and current) UNIX programmer, I am finding myself in a state of confusion when it comes to DB programming in windows. Maybe you have to, that's why I'm asking this here. In UNIX I get the libraries I need to talk to the database and use SQL statements to do it all. I connect, query, then parse the results. I'm looking for something as simple to do under Windows. If it helps, I'm looking for something very php (www.php.net) like in syntax: connect(params), execute(sql statement), fetch_array(results), disconnect(). Most important no note that the fetch_array returns tabel data as record=fetch_array(query_result); record[field]="some val". Alternative to that is fetch_row which you can use the index (column number) of the field to get that value. Is there anything like that in Microsoft? Do I have to use classes of CDatabase and CRecordset? It looks like I have to jump through a lot of hoops to get something simple working.
Secondly, what are the installation requirements for the particular methods? Must I always require Microsoft Access be installed? Under UNIX I can make such a requirement because there always is a UNIX admin handy to install it. But on a PC I cannot make that assumption. I have to assume that any inexperianced user can handle it. Which also raises the question, how do I initialize a database under windows? Could I use hard coded SQL statements?
Thanks in advance
|
|
|
|
|