|
I am converting a dos app to a windows app. The application changes passwords for given a given user. The dos application accepts servername, username, and password as cmd line arg's. They are defined as char username[50], password[128], etc.
My dialog takes the username and password as CString's.
How can I convert the CString to make it compatible with the char [50], etc above?
Thanks!
"Keyboard Error - Press F1 to Continue"
|
|
|
|
|
To make a CString from char[]:
char username[50];
CString str;
str = username;
To make a char[] from CString:
CString str;
char username[50];
memset(username, 0, 50);
strncpy(username, str.LockBuffer(), 50-1);
str.UnlockBuffer();
Hope that helps
Dominik
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
(doesn't work on NT)
|
|
|
|
|
The calls to LockBuffer() and UnlockBuffer() are not necessary as the second parameter to strncpy() is expecting a LPCSTR , which CString provides. The same is true for GetBuffer() and ReleaseBuffer() .
|
|
|
|
|
Thanks! That worked great.
Frank
"Keyboard Error - Press F1 to Continue"
|
|
|
|
|
i'm writting an application using c# that needs to communicate with the parallel port efficiently.
since win32 API are not fast enough, i wrote a win32 dll in c++ which uses assembly instructions to communicate with the port.
to read values from the port, i have a dll export which just returns the current value read from the port.
doing these read operation many times through dllImport is not efficient. so i need a way to return multiple values from the dll export.
i'm not sure whether it is possible to communicate with parallel port directly from c#.
please help me.
thanks.
|
|
|
|
|
I would ask this question in the CodeProject C# forum.
Dominik
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
(doesn't work on NT)
|
|
|
|
|
Hi,
Can someone tell me how to implement a UDP client. I already did a TCP client (it works fine), and read some of the MSDN on some differences. Is the only difference that I use SOCK_DGRAM instead of SOCK_STREAM ? Where can I find a list of the protocols address family (af) for the function socket?
Can some tell me where to find a detailed article or some sample code.
Thanks.
Jimmy
Just cause I am 15, doesn't mean I'm dumb! (I'll really be 4 on Feb. 29...the year 2004)
|
|
|
|
|
Well, during the creation you just pass the SOCKET_DGRAM instead of SOCKET_STREAM .
Then you might 'bind ' it to the local port (selecting the client side port number - unusual in tcp). If you don't do it it will choose the port automatically as in tcp, but most udp protocol expects also known client port, so usually you have to do it.
Then the usage is slightly different - on write side whatever you write it will send a packet immediatelly (no nagle alg. as in tcp) therefore if you write every byte separately, there will be separate packet for every byte (thus big overhead). You also have to specify the destination address - this is in tcp taken from the 'connect ', but there's no connect, because it's connectionless socket .
Reading part - here you can use the recvfrom or WSARecvFrom functions which returns also the address from where the datagram was sent and you can process it.
That's the difference between udp and tcp - in udp you can communicate with several computers using one socket. Therefore you have to specify the address in write and receive it in read.
Another issue with udp is that it's not reliable - it's only best effort service, so during design of the protocol you have to think about the fact, that the packets (data) can be lost - this is normally controlled by tcp and in that case the data are resend, but it's not valid in udp, here it's up to you.
That's just brief description of udp-tcp differences. I hope it's not too much confusing
|
|
|
|
|
Hi. This my first post here, so be gentle
I'm creating a level editor, in the vein of id Software's q3radiant, and I've hit a snag. I've been developing it for about 3 months, using MFC/C/C++, and haven't had the need to save any of the maps I've been making. Now I'm coming to the part where I have to be able to save and load my maps to progress. "All well and good," I thought. "I'm using the document/view architecture, it shouldn't be too much trouble." I was wrong, apparently.
I've created some window classes to provide the 2D and 3D functionality I need (they use OpenGL for rendering), and then used a couple of static CSplitterWnds to make the windows. This has worked perfectly up to now. There is a texture window (CTexWnd : CWnd) on the right, and then a nested CSplitterWnd on the right with three 2D windows (C2DWnd : CWnd) and a perspective window (C3DWnd : CWnd). I haven't used the view or document created by the app wizard (CMyEditorView and CMyEditorDoc, respectively), as the need hasn't arisen until now.
I've come to save my maps, but the Save and Save As menu items are greyed. The resource IDs (ID_FILE_SAVE and ID_FILE_SAVE_AS) are correct, but they're still unusable. I created a small test program, and dug around in MFC until I found out the problem: I wasn't creating a CMyEditorView, and therefore, the messages weren't being routed to my CMyEditorDoc. I created a CMyEditorView in place of one of 2D windows, and, lo and behold, the Save and Save As buttons were available. However, now I'm confused. How do I link the document to all of the windows, or none of them? How do I link it so that the document can be used to store my map, and save/load it? I have to keep using C2DWnd instead of CMyEditorView, but it would seem that's not an option. Is there any way I can get out of this sticky problem, and save/load my maps using the document? I think there's other modelling software which uses the SDI environment and splitter windows, but still uses the document/view architecture. Thanks in advance for any replies, and thanks for reading this rather large post, but I thought I'd probably better get in as much detail in possible
PS. I can post code and/or screenshots, if it's relevant...
Chris Mantle
|
|
|
|
|
Jeez, if you guys can't help me, I must be in trouble. Ah well, back to the drawing board...
|
|
|
|
|
I hjave a need to detect one of the following 3 states for a CD writer drive.
1. No media in the drive
2. Unformatted / Blank media in the drive
3. Media with a valid CDFS on it in the drive.
So far all of the IOCTL calls I have explored give me the same results from an empty drive as they do from one containing blank or unformatted media.
Any help gratefully received.
|
|
|
|
|
You should be able to extrapolate from this:
bool IsMediaPresent( void )
{
MCI_OPEN_PARMS mciOpen = {0};
MCI_STATUS_PARMS mciStatus = {0};
MCIERROR mciError;
mciOpen.lpstrDeviceType = "cdaudio";
mciError = mciSendCommand(NULL, MCI_OPEN, MCI_OPEN_TYPE, (DWORD) ((LPVOID) &mciOpen));
if (0 == mciError)
{
mciStatus.dwItem = MCI_STATUS_MEDIA_PRESENT;
mciError = mciSendCommand(mciOpen.wDeviceID, MCI_STATUS, MCI_STATUS_ITEM, (DWORD) ((LPVOID) &mciStatus));
mciError = mciSendCommand(mciOpen.wDeviceID, MCI_CLOSE, 0, NULL);
}
return (1 == mciStatus.dwReturn);
}
|
|
|
|
|
First of all many thanks for taking the time to provide an answer , it is much appreciated. The code fragment works in detecting an empty drive or a drive containing a formatted CD, however it returns exactly the same responses for a drive containing a blank unformatted CD as it does for an empty drive. This is the same problem I have experienced using the CD IOCTL calls from the DDK, they all tend to return 21 (device not ready). The application I am trying to write is a service that will kick off a third party app to write a CD overnight if there is valid media in the drive. I don't want to kick it off if there isn't because the app will sit there with a non displaying dialog waiting for a response.
|
|
|
|
|
I derived the tab control and attached two dialogs.a piece of code
and see the attached pic,where two dialog attached to the tab.
class CBaseTabCtrl : public CTabCtrl
{
// Construction
public:
CBaseTabCtrl(int nType = BTC_NONE);
CDialog *m_tabPages[2];
int m_tabCurrent;
int m_nNumberOfPages;
//Operation
public:
//tab
void Init();
void SetRectangle();
....
CBaseTabCtrl::CBaseTabCtrl(int nType)
{
m_tabPages[0]=new CCamera1CtrlDlg;//CCamera1CtrlDlg is the dialog (IDD_CAMERA1)'s wrapper class.
m_tabPages[1]=new CCamera2CtrlDlg;//CCamera2CtrlDlg is the dialog (IDD_CAMERA2)'s wrapper class.
}
CBaseTabCtrl::~CBaseTabCtrl()
{
delete m_tabPages[nCount];
}
void CBaseTabCtrl::Init()
{
m_tabCurrent=0;
m_tabPages[0]->Create(IDD_CAMERA1, this);
m_tabPages[1]->Create(IDD_CAMERA2, this);
m_tabPages[0]->ShowWindow(SW_SHOW);
m_tabPages[1]->ShowWindow(SW_HIDE);
SetRectangle();
}
in the parent dialog's Oninitdialog()
BOOL CTestDlg::OnInitDialog()
{
...
m_tabCtrl.InsertItem(0, "ÉãÏñ»ú1", 0);
m_tabCtrl.InsertItem(1, "ÉãÏñ»ú2", 1);
m_tabCtrl.Init();
...
}
so when I handle the clicked button 's message in test dialog(parent dialog),I want to send message to the the IDD_CAMERA1 dialog.so I can handle the defined my message in IDD_CAMERA1 dialog .
above,how to send user defined the message to the IDD_CAMERA1 dialog .
attached IMG (there is a link)
|
|
|
|
|
I had solved the problem use the code:
m_tabCtrl.m_tabPages[0]->SendMessage(WM_COMMAND,(WPARAM)IDC_MODLESSDIALOGBTN);
|
|
|
|
|
" Linking...
MAPI.lib : fatal error LNK1136: invalid or corrupt file
Error executing link.exe. "
this is the error which i get when executing a file that includes mapi.dll
kindly help me in debugging it!
ranjani
|
|
|
|
|
There's nothing to debug. The file has either a corrupt header, or has a zero size. It sounds like you need to reinstall VS, thus getting a non-corrupt copy of mapi.lib.
|
|
|
|
|
What version of Visual C++ are you using?
I thought MAPI required MAPI32.lib?
Isn't MAPI.lib a 16bit lib?
Michael
'War is at best barbarism...Its glory is all moonshine. It is only those who have neither fired a shot nor heard the shrieks and groans of the wounded who cry aloud for blood, more vengeance, more desolation. War is hell.' - General William Sherman, 1879
|
|
|
|
|
MAPI>lib is a 16 bit lib only
wat iam using is VC++ 6.0 version!
donno what the problem is!
does MAPI require MAPI32.libb??
ranjani
|
|
|
|
|
In my MAPI programs I link with MAPI32.lib not MAPI.lib
Michael
'War is at best barbarism...Its glory is all moonshine. It is only those who have neither fired a shot nor heard the shrieks and groans of the wounded who cry aloud for blood, more vengeance, more desolation. War is hell.' - General William Sherman, 1879
|
|
|
|
|
Hi
Anyone knows how i can change the color of the border of a group box?
Greetings
Jens
|
|
|
|
|
One solution is to derive a class from the group box control. Do custom drawing.
Kuphryn
|
|
|
|
|
i thought something like that
but i'm not that good at drawing things
any tutorials of it?
greetings
Jens
|
|
|
|
|
Look in CodeProject code section.
Kuphryn
|
|
|
|
|
It does not seem to be possible with CPen... anyone knows of an alternative? Could not find an article here with an alternative to CPen...
Any ideas?
Thanks
|
|
|
|
|