|
|
IlanTal wrote: I don't want to launch multiple instances of it
See this[^] thread for your question and you said you used of WinExec,its of MSDN :
"This function is provided only for compatibility with 16-bit Windows. Applications should use the CreateProcess function"
|
|
|
|
|
IlanTal wrote: So, first of all, if there is a better choice, please let me know. WinExec() does the job nicely since it is so simple.
See here.
IlanTal wrote: Here is my real question. The second application takes a lot of memory and I don't want to launch multiple instances of it. So I would like something to check to see if it is running. If not, launch it. If yes, jump to the instance which is running.
Is there an easy way to do this?
See here.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
You can use CreateProcess or ShellExecute or ShellExecuteEx depending on ur req.
|
|
|
|
|
Thanks to all for the replies. It is nice to receive so many replies.
They were useful and the problem is now solved (using a mutex).
Ilan
|
|
|
|
|
Use CreateProcess() and keep the handle around. If the handle is NULL, don't let the program be executed again.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Hi,
I have the need for true WYSIWYG text output using VC++ 2003. I am using text boxes. I have seen the WYSIWYG example on Codeguru, but it does not expand tabs. I either need to know how to expand tabs like the CEdit control does (without using DrawText), or implement the RichTextBox. Does anyone know if the RichTextBox supports WYSIWYG printing - or how to do it?
Even the knowledge of a third party ActiveX control would be helpful.
Thanks,
-Gabe
|
|
|
|
|
If you use the same font as the "text box" (edit control?) then you should be able to render the
text the same as the system control does.
Maybe the TabbedTextOut() API will help if you need more control over tabs.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Thanks Mark. I am doing all that. Problem is that Windows has inherent issues with these functions (DrawText, TabbedTextOut) due to the integer-based text metrics. (See p 972 in Feng Yuan's Windows Graphics Programming book). DrawText handles tabs and works OK until you want to zoom or print. Due to the rounding errors you get slightly different results. He has some examples that are a little difficult to follow and do not support things such as tabs, DT_CENTER, etc. Never thought this would be so difficult. -Gabe
|
|
|
|
|
Hi,
The first is about the member "palVersion" in the struct LOGPALETTE. MSDN says:
The LOGPALETTE structure defines a logical color palette.
typedef struct tagLOGPALETTE { // lgpl
WORD palVersion;
WORD palNumEntries;
PALETTEENTRY palPalEntry[1];
} LOGPALETTE;
palVersion: Specifies the version number of the system.
palNumEntries: Specifies the number of entries in the logical color palette.
palPalEntry: Specifies an array of PALETTEENTRY structures that define the color and usage of each entry in the logical palette.
But... what is exactly this parameter for? I guess is something it may change depending on the computer where my application is being executed. How can I determine in Runtime this value? I have seen an example that writes 0x300 but I don't know if it is a good idea to write the same as in the example.
The case is that I want to make DIBs from the Bitmaps I made in the resource editor because of the problem I explain in other message ( Printing Problems[^] if possible I would like to have answers for the other quesion I made there). As those .rc Bitmaps are made in 20-Colors... Do I really need the Palette? Or may I use
hPal = (HPALETTE) GetStockObject (DEFAULT_PALETTE);
to make the DIB of those bitmap-resources? I think it will be much easier, and I suppose it won't give me any problem about compatibility with printers... Or am I wrong?
I know is difficult to answer a message, specially in Forums with such a volume of posts like this but, I need a bit of help with this (and the other message) at least to understand things. I will make the rest by myself.
Thanks
Edit: Default are 20 colors not 16...
-- modified at 11:27 Wednesday 9th May, 2007
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
|
|
|
|
|
|
Nelek wrote: But... what is exactly this parameter for?
I've never found any documentation on LOGPALETTE.palVersion. I've always used 0x0300
Nelek wrote: As those .rc Bitmaps are made in 20-Colors... Do I really need the Palette?
This depends on the format of the DDB. If it's 1, 4, or 8 bitsperpixel then the data for each
pixel is an index into the palette associated with the device that the bitmap is dependent on.
For 16+ bits-per-pixel bitmaps, the color info is stored in each pixels data so no mapping to
a palette is necessary when converting to a DIB.
Since resource bitmaps are meant for display devices, the default system palette should work fine
if you need it for conversion.
If you use GetDIBits to do the conversion, GetDIBits will use the palette associated with the
DC passed to the function.
Here's another article: How To Convert Between Device-Dependent Bitmaps and DIBs[^]
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Hi,
Thanks a lot for your answers. I have successfully printed using the function DDBToDIB (...) that I found in one Roger Allen's article with some modifications. I have used no CPalette so it doesn't matter the question about the palVersion.
Anyways, although it is not needed anymore because it already works... I would like to understand the first question (about GlobalLock / GlobalUnlock and the other method) that I make the other post "Printing Problems" (Link above in the first message of this thread). I will be very thankfull if someone can answer it.
Another time, thanks. I was desperated, I can now continue working
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
|
|
|
|
|
What is meant by a servicehost and what is the necessity of the same? Why does in XP service run under network and user privilege. One reason which I know a a bit is that microsoft does not want third party services to run under the same privileges.
|
|
|
|
|
I'm not sure about servicehost - I don't see any reference to it related to Windows services.
The Service Control Manager (SCM) provides control over services.
XP service applications run under whatever user account that you set it up to use. They run
in the context of a user account, which can be a built-in account, an account that has been set
up specifically for the service, or any user account.
You can run a service in the context of an account with any priveledges you want.
For safety, the account should have only the priveledges it needs to function.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Svchost.exe is the file name for the generic Windows process called Service Host which resides in Windows\System32\. Since it acts as a host, it can collect multiple services together and run them in a common environment. This results in a more efficient arrangement since it reduces boot time and system overhead by eliminating the need to run dozens of separate services, each in their own memory spaces. Different groups of Windows services have different requirements in terms of system access (privilege) and security, which is why separate instances of svchost.exe are needed.
To show just the instances of svchost.exe and the process running under each instance, type this in a CMD window exactly as shown:
tasklist /svc /fi "imagename eq svchost.exe"
Best wishes,
Hans
|
|
|
|
|
I think tasklist requires "WinXP Pro" or "Win 2003 Server".
Perhaps Vista has got it in some standard edition.
An alternative way would be to use Russinovich's Process Explorer[^] to get the same information.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Roger Stoltz wrote: I think tasklist requires "WinXP Pro" or "Win 2003 Server".
You're probably right.
Best wishes,
Hans
|
|
|
|
|
Hi all,
I has been created one MFC extension dll called SRecordset.dll that is
my .h file..
#pragma once<br />
#include <afxwin.h><br />
#include <afxdb.h><br />
<br />
class AFX_EXT_CLASS SRecordset : public CObject<br />
{<br />
DECLARE_SERIAL(SRecordset)<br />
<br />
<br />
public:<br />
SRecordset(void);<br />
<br />
public:<br />
~SRecordset(void);<br />
<br />
protected:<br />
CStringArray saDataContainer; <br />
short iNumFldCount; <br />
long iNumRec; <br />
int iRecCount; <br />
int iTotalSize; <br />
int iRecordState; <br />
int iLocalIndex; <br />
public:<br />
BOOL SSOpen(CDatabase &dbConnectedObj,CString sQuery); <br />
BOOL SSIsOpen(void); <br />
void SSClose(void); <br />
public:<br />
BOOL SSIsBOF(void); <br />
BOOL SSIsEOF(void); <br />
public:<br />
void SSGetFieldValue(int iIndex,CString &FldValue); <br />
short SSGetFieldCount(void); <br />
long SSGetRecordCount(void); <br />
long SSGetCurrentRecordCount(void); <br />
public:<br />
void SSMoveNext(void); <br />
void SSMovePrevious(void); <br />
void SSMoveFirst(void); <br />
void SSMoveLast(void); <br />
public:<br />
virtual void Serialize(CArchive& ar); <br />
};<br />
I could create dll successfully. But, it won't support to the client application meanwhile that will be thrown linker error only when i call the SSOpen(CDatabase &dbConnectedObj,CString sQuery) function during runtime
part of code of my client app...
void CtestingDlg::OnBnClickedOk()<br />
{<br />
<br />
<br />
CDatabase db;<br />
CString sIp,sDb,sPwd,sConn,sPort,sUn;<br />
sIp="192.168.2.17";<br />
sPort="5432";<br />
sPwd="fasp";<br />
<br />
<br />
try<br />
{ <br />
sConn = "DRIVER={PostgreSQL ANSI};SERVER=" + sIp + ";port=" + <br />
sPort + ";DATABASE=" + sPwd + ";UID=" + sPwd + ";PWD=" + sPwd + ";";<br />
db.OpenEx(sConn);<br />
AfxMessageBox("Success");<br />
}<br />
catch(CDBException *e)<br />
{<br />
MessageBox("Database Connection Refused."+e->m_strError,"DataBase <br />
Connection Error",MB_OK|MB_ICONERROR);<br />
e->Delete();<br />
<br />
}<br />
<br />
<br />
SRecordset set1;<br />
<br />
set1.SSOpen(db,"select name from master;");<br />
set1.SSGetFieldCount();<br />
set1.SSGetRecordCount();<br />
set1.SSClose();<br />
<br />
OnOK();<br />
}<br />
Error is.....
testingDlg.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: int __thiscall SRecordset::SSOpen(class CDatabase &,class ATL::CStringT<char,class strtraitmfc_dll<char,class="" atl::chtraitscrt<char=""> > >)" (__imp_?SSOpen@SRecordset@@QAEHAAVCDatabase@@V?$CStringT@DV?$StrTraitMFC_DLL@DV?$ChTraitsCRT@D@ATL@@@@@ATL@@@Z) referenced in function __catch$?OnBnClickedOk@CtestingDlg@@QAEXXZ$0
could you help me please?
|
|
|
|
|
Are you linking with SRecordset.lib?
Best wishes,
Hans
|
|
|
|
|
yah i already done,but there is an error raised, when i calld only SSOpen() function not other function calls...
void CtestingDlg::OnBnClickedOk()<br />
{<br />
<br />
<br />
CDatabase db;<br />
CString sIp,sDb,sPwd,sConn,sPort,sUn;<br />
sIp="192.168.2.17";<br />
sPort="5432";<br />
sPwd="fasp";<br />
<br />
<br />
try<br />
{<br />
sConn = "DRIVER={PostgreSQL ANSI};SERVER=" + sIp + ";port=" +<br />
sPort + ";DATABASE=" + sPwd + ";UID=" + sPwd + "WD=" + sPwd + ";";<br />
db.OpenEx(sConn);<br />
AfxMessageBox("Success");<br />
}<br />
catch(CDBException *e)<br />
{<br />
MessageBox("Database Connection Refused."+e->m_strError,"DataBase<br />
Connection Error",MB_OK|MB_ICONERROR);<br />
e->Delete();<br />
<br />
}<br />
<br />
<br />
SRecordset set1;<br />
<br />
set1.SSOpen(db,"select name from master;");<br />
set1.SSGetFieldCount();<br />
set1.SSGetRecordCount();<br />
set1.SSClose();<br />
<br />
OnOK();<br />
}<br />
above the code thrown only one linker error for SSOpen() function...
please help me..
-- modified at 3:22 Thursday 10th May, 2007
|
|
|
|
|
You need to link to the lib file that is generated with your dll.
|
|
|
|
|
how to hide start menu.that was appeared when windows key is pressed.
|
|
|
|
|
Try a global hook.
Best wishes,
Hans
|
|
|
|
|
how to perform global hook.
|
|
|
|