|
I am modifying a project that uses Shell_NotifyIcon to add an application to the system tray. What I want is to prevent the same application running more than once. The project is not using MFC and I would prefer to keep it that way. Is there any way to detect the applications running in the System Tray using the API?
|
|
|
|
|
You could use the ::FindWindow(..)
hope that helps
|
|
|
|
|
You can enumerate the processes on the system, but this works differently for Win 9x and NT systems.
I can dig out some sample code if you need it, as I've used it to detect if a program was running, and if so to wait for it to finish.
Giles
|
|
|
|
|
I to all.
I've a little problem on trying to intercept the WM_QUIT message on an MFC based application.
I want to display a message on user which allow select to exit application or not.
I'm not using Document/View architecture so I don't need to mark any document to dirty.
Thanks to anyone.
|
|
|
|
|
Try to put this code in OnAppExit of your CMainFrame class
if (AfxMessageBox("Do you really want to exit?",MB_YESNO) == IDYES)
{
CMainFrame::OnClose();
}
Lio.
|
|
|
|
|
Thank you for this code Lio, now another question: and if I have a CListCtrl Document?
Thanks a lot.
|
|
|
|
|
I created a dll (Win32- Dynamic Link Library)
and I'm having a trouble loading that DLL ( using 'LoadLibrary' / 'GetModuleHandle')
*** I keep getting a NULL or the handle is invalid. (GetLastError() returns 6 or 126) ***
PLEASE, I've been on then about 6 hours straight.
Is there anything I'm missing ????
NOTES:
1: Could it be that functions can not be importable?
2: Could it be that the released .dll file is damaged?
please H E L P ! ! !
Name: STR
|
|
|
|
|
Hi,
The GetLastError() function of yr's says "Handle invalid"(6) and "Module can't be found"(126).So, I hope problem with the Dll path u have given.First find out in which path yr Dll is present and give that path in the LoadLibrary()/GetModuleHandle() function.Then check for the handle.This could be the only problem I hope.Let me know if it works.
Regards,
yamini.
|
|
|
|
|
Thanks for your quick answer
But...
That is not the problem.
I could this function like this:
1: 'LoadLibrary("c:\\MyDLL2.DLL")'
or
2: 'LoadLibrary(_T("c:\\MyDLL2.DLL"))'
or
3: 'LoadLibrary((LPCTSTR)"c:\\MyDLL2.DLL")'
*) I added 'C:\MyDLL2.lib' in Project->Settings...
*) I added 'C:\' to the system path
*) I added 'C:\' to the project path (in Project->Settings)
I don't know what to do
Name: STR
|
|
|
|
|
Launch depends.exe - Dependency Walker which is a part of MsVisual C++. Drag and drop this Your dll onto depends.exe window. See what it will say.
Probably some dll which is required by Your dll cannot be found. For example the dll You are loading needs msvcrt.dll(insert any), which is not on the path.
Hope, this helps
|
|
|
|
|
Hi,
I use CreateFile, ReadFile, WriteFile, COMMSTAT, CLEARCOMMERROR for using the SerialPort in RS422.
I would like some help for settings the DCB.
I use my little program for communicate with a device.
In my settings , I would like :
- 38400 Bauds,
- 8 Bits,
- 1 Stop Bit,
- EVEN Parity,
- Binary Mode,
- Set RTS and DTR Enable,
- HandShaking comRTS.
If anyone can check my code for correct it because it doesn't working with my interface in RS422. But if I use this with hyperterminal in RS232 NullModem cable all are ok.
Best regards
// Open SerialPort (nComport = the port number )
//----------------------------------------------
//
// HANDLE hPort;
DWORD dwError; // dwThreadID;
DCB PortDCB;
COMMTIMEOUTS CommTimeouts;
CString strComPort;
strComPort.Format("COM%d", nComport);
// Open the serial port.
BETACART_hPort = CreateFile (strComPort, // Pointer to the name of the port
GENERIC_READ | GENERIC_WRITE,
// Access (read/write) mode
0, // Share mode
NULL, // Pointer to the security attribute
OPEN_EXISTING, // How to open the serial port
0, // Port attributes
NULL); // Handle to port with attribute
// to copy
// If it fails to open the port, return FALSE.
if ( BETACART_hPort == INVALID_HANDLE_VALUE )
{
// Could not open the port.
MessageBox (TEXT("Le Port RS sélectionné n'existe pas"),
TEXT("Error"), MB_OK);
dwError = GetLastError ();
}
PortDCB.DCBlength = sizeof (DCB);
// Get the default port setting information.
GetCommState (BETACART_hPort, &PortDCB);
// Change the DCB structure settings.
PortDCB.BaudRate = 38400; // Current baud
PortDCB.fBinary = TRUE; // Binary mode; no EOF check
PortDCB.fParity = TRUE; // Enable parity checking.
PortDCB.fOutxCtsFlow = FALSE; // No CTS output flow control
PortDCB.fOutxDsrFlow = FALSE; // No DSR output flow control
PortDCB.fDtrControl = DTR_CONTROL_DISABLE; //DTR_CONTROL_HANDSHAKE; //DTR_CONTROL_ENABLE;
// DTR flow control type
PortDCB.fDsrSensitivity = FALSE; // DSR sensitivity
PortDCB.fTXContinueOnXoff = TRUE; // XOFF continues Tx
PortDCB.fOutX = FALSE; // No XON/XOFF out flow control
PortDCB.fInX = FALSE; // No XON/XOFF in flow control
PortDCB.fErrorChar = FALSE; // Disable error replacement.
PortDCB.fNull = FALSE; // Disable null stripping.
PortDCB.fRtsControl = RTS_CONTROL_HANDSHAKE; //RTS_CONTROL_ENABLE;
// RTS flow control
PortDCB.fAbortOnError = FALSE; // Do not abort reads/writes on
// error.
PortDCB.ByteSize = 8; // Number of bits/bytes, 4-8
PortDCB.Parity = EVENPARITY; //ODDPARITY; // 0-4=no,odd,even,mark,space
PortDCB.StopBits = ONESTOPBIT; // 0,1,2 = 1, 1.5, 2
// Configure the port according to the specifications of the DCB
// structure.
if (!SetCommState (BETACART_hPort, &PortDCB))
{
// Could not configure the serial port.
MessageBox (TEXT("Unable to configure the serial port"),
TEXT("Error"), MB_OK);
//dwError = GetLastError ();
}
// Direct the port to perform extended functions SETDTR and SETRTS.
// SETDTR: Sends the DTR (data-terminal-ready) signal.
// SETRTS: Sends the RTS (request-to-send) signal.
EscapeCommFunction (BETACART_hPort, SETDTR);
EscapeCommFunction (BETACART_hPort, SETRTS);
youssef
|
|
|
|
|
Hi Youssef
I'm not a guru here, but after a quick look at the specs I'd say that RS422 and RS232 are almost but not quite compatible. RS232 uses a 3 wire interface, while RS422 uses a 4 wire connection, refered to as 'balanced' - I think you will not be able to go directly from your PC to the RS422 device.
But, there are converters available to go between RS232 and RS422 devices - probably available for something like 50USD. Search for RS422 on Google, you'll find a bunch!
HTH
T
later...
Of course, if you already have one of these converters, then I'm being presumptious, and will shut up and go away...
BTW what kind of device is it?
|
|
|
|
|
hi,
in the Internet Options' connection tab, there is
a group of radio buttons with following value:
1) never dial a connection
2) dial whenever a connection is not present
3) always dial my default connection.
where the value is stored? and can we set this in the code?
thanks.
|
|
|
|
|
Hi
I have some question about DAO :
1 - When I use MFC wizard there is three choice
(Snapshot , Dynaset , Table),so what difference ...
2 - If my access file has two tables I have two problems :
A- How I can determine which table I want to add record ...
B- When I use code like this
m_pSet->AddNew();
m_pSet->m_id=1; //table 1
m_pSet->m_name="Ahmad"; //table 1
m_pSet->m_id2=1; //table 2
m_pSet->m_phone=21598356; //table 2
m_pSet->Update();
a meesage box appeare and tell me that :
Can't update. Database or object is read only
3- How I can use SQL statements with VC++ 6 ...
Thank you
AHMAD ALWASHALI
|
|
|
|
|
Here's some short replies. I really recommend that you read some books on the subject, as it is a huge one. "Microsoft Jet Database Engine Programmers Guide" used to be online on MSDN, but I can't find it there anymore. It's a bit outdated anyway, but gives you a good grip on DAO (although it's written for VB!!!). If you have some MSDN Library CD's from last year I guess it will be there.
The answers:
1: snapshot: the resultset is a snapshot of the data in the database. Changes to the data in the db after the snapshot is opened is not reflected in the snapshot. The snapshot is read-only (and I vaguely remember something about it being forward-only also).
Dynaset: the resultset represents the actual data in the database at the time you fetch (i.e. read) the data. Updateable.
Snapshots and Dynasets are the result of a query, i.e. an SQL statement.
Table: as Dynaset, but gives you all the fields of one particular table. Among other things very useful if you want to browse the table, or as a basis for a data-entry form in your program.
2: You probably asked for a snapshot - they're read-only.
3: Use a QueryDef object. Here you can set the SQL text.
good luck
Steen
|
|
|
|
|
Thank you very much,your answer was very useful ...
AHMAD ALWASHALI
|
|
|
|
|
Hi
- Microsoft Communication Control which it
as Active X control ,,,
I think it's for dialing by FaxModm,so any one can tell
me how I can use it ,,,
I hope if you can tell me about any web site can give
me a simple about that...
- And if I used TAPI function ,
is it must the DIALER(MICROSOFT) programe run to
do the function like Address Book project
which you can find it in codeproject(Home >> Samples >> General )???
And I hope if you can tell me about any web site can give
me a simple and explain about TAPI...
Thank you
AHMAD ALWASHALI
|
|
|
|
|
How do I get a reference to the document from MainFrame?
|
|
|
|
|
Hi all,
I'm having great problems sending email from an NT service- the only place I've found it mentioned was in MSDN referring to Extended MAPI
Given that I don't want to go to such great lengths to do it, can anyone let me know of a way to send email from a service? All I need to do is send a simple message to a recipient. Thanks very much for any help.
Cheers
NB
|
|
|
|
|
I've tried using CDO's IMessage (in a very simple manner), but for some reason it calls int 3 ... ? ... and just generally dies with a message about an invalid heap pointer deep in the cdo code.
|
|
|
|
|
You can try using SMTP.
Here are some Classes designed to get around problems associated with services : http://www.codeproject.com/internet/csmtpconn.asp
I think there is a newer version at the authors site. They are really easy to use, and work well.
Giles
|
|
|
|
|
thanks, giles, i'll have a look at them
|
|
|
|
|
BTW, there are some classes available through PJ Naughter's site that port Naughter's code from MFC to STL, which saved me a great hassle.
As you said, very easy to use, did the trick fantastically.
|
|
|
|
|
Which ones? That could be very useful.
Thanks,
Giles
|
|
|
|
|
all of the classes from 1.21, I believe, also compiled into a dll that exports a 'quick & easy' PJSendMail() function (perfect for what I needed to do!)
you can download the code at http://naughter.com/download/pj_smtp_stl.zip
|
|
|
|