|
Can anyone tell me ho to use RegisterServiceProcess
I need to register my application as service
but rhis function is undocmented api
any help or resources about undocmented api
would be nice
MR.Byte
|
|
|
|
|
|
I need to create a shortcut on the desktop by my
program
note: I Know nothing about shell programming
thanks in advance
MR.Byte
|
|
|
|
|
The following code should do:
HRESULT CreateShortcut(LPCSTR pszShortcutFile, LPSTR pszLink,
LPSTR pszDesc)
{
HRESULT hres;
IShellLink* psl;
hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
IID_IShellLink, &psl);
if (SUCCEEDED(hres))
{
IPersistFile* ppf;
hres = psl->QueryInterface(IID_IPersistFile, &ppf);
if (SUCCEEDED(hres))
{
WORD wsz[MAX_PATH];
hres = psl->SetPath(pszShortcutFile);
if (!SUCCEEDED(hres))
AfxMessageBox("SetPath failed!");
hres = psl->SetDescription(pszDesc);
if (!SUCCEEDED(hres))
AfxMessageBox("SetDescription failed!");
MultiByteToWideChar(CP_ACP, 0, pszLink, -1, wsz, MAX_PATH);
hres = ppf->Save(wsz, TRUE);
ppf->Release();
}
psl->Release();
}
return hres;
}
Deepak Khajuria
|
|
|
|
|
Deepak Khajuria wrote:
hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, &psl);
I get an error when giving &psl to CoCreateInstance... the error disappears when I cast it to a void** pointer... but then the call fails...
Actually, what my only wish to do is to get the target path of a link and I know the path to the link. Any ideas?
|
|
|
|
|
Hi,
I have a problem in getting the no of windows open under the Windows menu when i create my own dynamice menu. If i load the menu from the resource all the opened windows are displayed under the Windows menu by default. How to get the same functionality in my dynamic menu under any one of the menu items.
Thanks in Advance
San
|
|
|
|
|
AFAIK, you have to enumerate all MDI child windows yourself and add menu items yourself. Your mainframe window has an undocumented member, m_hWndMDIClient, which is a parent for all child frames. You should use EnumChildWindows with MDI client to get the HWNDs of MDI children. GetWindowText will give you the captions.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
i made an COM - Server, works fine.. now i've tried to add a Method to the Interface with a HWND as Paramter .. it compiles well, but the linker is shouting?? do you know which lib i forgot to include..
TEST_p.obj : error LNK2001: unresolved external symbol _HWND_UserFree@8
TEST_p.obj : error LNK2001: unresolved external symbol _HWND_UserUnmarshal@12
TEST_p.obj : error LNK2001: unresolved external symbol _HWND_UserMarshal@12
TEST_p.obj : error LNK2001: unresolved external symbol _HWND_UserSize@12
thanks in advance
bernhard
""Politicians and diapers have one thing in common. They should both be changed regularly and for the same reason."
|
|
|
|
|
I was under the impression you were constrained in what parameters could be passed into a COM object, and that HWND was not one of them. It's just a long, why don't you try to pass it as one ?
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
|
|
|
|
|
Add ole32.lib to your TESTps.mk link build rule. It should look something like:
TESTps.dll: dlldata.obj TEST_p.obj TEST_i.obj
link /dll /out:TESTps.dll /def:TESTps.def /entry:DllMain dlldata.obj TEST_p.obj TEST_i.obj \
kernel32.lib rpcns4.lib rpcrt4.lib ole32.lib oleaut32.lib uuid.lib \
|
|
|
|
|
I attached tooltips to buttons derived from CWnd. Tooltips are shown only when EnableWindow( false) of selected button. How can I enable tooltips for buttons which have EnableWindow( true) ?
Hans
---------------
ON_NOTIFY_EX( TTN_NEEDTEXT, 0, OnToolTipNotify)
BOOL CKurzzeitDlg::OnToolTipNotify( UINT id, NMHDR * pNMHDR, LRESULT * pResult )
{
TOOLTIPTEXT *pTTT = (TOOLTIPTEXT *)pNMHDR;
CString csTipText;
UINT nID =pNMHDR->idFrom;
if (pTTT->uFlags & TTF_IDISHWND)
{
// idFrom is actually the HWND of the tool
nID = ::GetDlgCtrlID((HWND)nID);
if(nID)
{
// Select which Control has been hit by cursor
switch( nID)
{
case IDC_BUTTON1:
csTipText = "My Text";
break;.... }
m_Button.EnableWindow( false); -> I´ll have Tooltips
m_Button.EnableToolTips( true);
m_Button.EnableWindow( true); -> No Tooltips are shown
|
|
|
|
|
Did you set the Notify style for each of the buttons in the dialog editor?
Roger Allen the man
|
|
|
|
|
Can you please give me source code for the second way?I'm loading items from a database
|
|
|
|
|
Basically, you want to avoid copying text during combobox load. Each item is marked as 'callback' - whenever combo actually needs the text (when it needs to repaint or show the dropdown list), it will ask your app. The loading is simple - you just pass LPSTR_TEXTCALLBACK as item text.
COMBOBOXEXITEM cbitem;
cbitem.mask = CBEIF_TEXT;
imax = ...;
for (int i = 0; i < imax; i ++)
{
cbitem.iItem = i;
cbitem.pszText = LPSTR_TEXTCALLBACK;
m_cbx.InsertItem(&cbitem);
}
Then, you should handle CBEN_GETDISPINFO notification in the parent window (probably this will be a dialog, property page or formview). Use ClassWizard to add the appropriate handler.
void CYourDialog::OnGetdispinfoNodeType(NMHDR* pNMHDR, LRESULT* pResult)
{
NMCOMBOBOXEX *pNMCBX= (NMCOMBOBOXEX *)pNMHDR;
pNMCBX->ceItem.pszText = someTable[pNMCBX->ceItem.iItem];
*pResult = 0;
}
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Does anyone know how to find installed application on computer, like application listed in Add/Remove programs icon.
Thank's a lot.
|
|
|
|
|
Look up this Registry Key
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
Nish
|
|
|
|
|
Add/Remove stores the list in the Registry. You can read from the same location to find the apps installed.
On 2000 the path is:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
Deepak Khajuria
|
|
|
|
|
Ok,
Thank's a lot everybody.
But now my other problem is how to find "the start program file" for each entry (i have just the uninstall program in this registry key).
Sorry for my english
|
|
|
|
|
Uninstall branch in the registry doesn't contain filenames of application itself - note that sometimes one uninstall removes more than one .exe.
Depending on your definition of 'installed applications' you should look elsewhere. Maybe you should just scan the start menu?
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Could you tell me how scan the start menu ?
Thank's in advance
|
|
|
|
|
if I send an email with a *.jpg attachmen ,the route I must follow ,
1,I open the jpg file in binary mode;
2,I must call CBase64::Encode() to encode the attachment;
3,send the email.
4,when I receive the email,I muse call
CBase64::Decode() to decode the attachment.
what I say is right?
any suggetion?
now where can I get the standard class CBase64?
thank you in advance!
|
|
|
|
|
I did a similar thing to send binary files as attachments in a project of mine. I did it by overriding the CDocument::OnFileSendMail(0 function and adding code to modify what the attachments are etc.
I have included the function here in its entirity, some of the stuff may not be relevant to your problem.
void CRefinementProDoc::OnFileSendMail()
{
ASSERT_VALID(this);
ASSERT(_afxIsMailAvail);
CWaitCursor wait;
_AFX_MAIL_STATE* pMailState = _afxMailState;
if (pMailState->m_hInstMail == NULL)
pMailState->m_hInstMail = ::LoadLibraryA("MAPI32.DLL");
if (pMailState->m_hInstMail == NULL)
{
AfxMessageBox(AFX_IDP_FAILED_MAPI_LOAD);
return;
}
ASSERT(pMailState->m_hInstMail != NULL);
ULONG (PASCAL *lpfnSendMail)(ULONG, ULONG, MapiMessage*, FLAGS, ULONG);
(FARPROC&)lpfnSendMail = GetProcAddress(pMailState->m_hInstMail, "MAPISendMail");
if (lpfnSendMail == NULL)
{
AfxMessageBox(AFX_IDP_INVALID_MAPI_DLL);
return;
}
ASSERT(lpfnSendMail != NULL);
TCHAR szTempName[_MAX_PATH];
TCHAR szPath[_MAX_PATH];
BOOL bRemoveTemp = FALSE;
if (m_strPathName.IsEmpty() || IsModified())
{
CString old_filename ;
CString old_path ;
VERIFY(GetTempPath(_countof(szPath), szPath) != 0);
if (DatasetType == TYPE_DATASET)
{
old_filename = pntr->m_Filename ;
old_path = pntr->m_Path ;
sprintf(szTempName, "%s%s", szPath, pntr->m_Filename) ;
}
else
{
old_filename = mpntr->m_Filename ;
old_path = mpntr->m_Path ;
sprintf(szTempName, "%s%s", szPath, mpntr->m_Filename) ;
}
m_sending_as_attachment = TRUE ;
BOOL bModified = IsModified();
BOOL bResult = DoSave(szTempName, FALSE);
SetModifiedFlag(bModified);
if (!bResult)
{
TRACE0("Warning: file save failed during File.Send Mail.\n");
return;
}
bRemoveTemp = TRUE;
m_sending_as_attachment = FALSE ;
if (DatasetType == TYPE_DATASET)
{
pntr->m_Filename = old_filename ;
pntr->m_Path = old_path ;
}
else
{
mpntr->m_Filename = old_filename ;
mpntr->m_Path = old_path ;
}
SetPathName(old_path + "\\" + old_filename, FALSE) ;
}
else
{
lstrcpyn(szTempName, m_strPathName, _countof(szTempName));
}
#ifdef _UNICODE
char szTempNameA[_MAX_PATH];
_wcstombsz(szTempNameA, szTempName, _countof(szTempNameA));
#endif
TCHAR szTitle[_MAX_PATH];
if (!m_strPathName.IsEmpty())
AfxGetFileName(m_strPathName, szTitle, _countof(szTitle));
else
{
lstrcpyn(szTitle, m_strTitle, _countof(szTitle));
if (m_strTitle.Find('.') == -1)
{
CString strExt;
CDocTemplate* pTemplate = GetDocTemplate();
if (pTemplate != NULL &&
pTemplate->GetDocString(strExt, CDocTemplate::filterExt))
{
lstrcat(szTitle, strExt);
}
}
}
#ifdef _UNICODE
char szTitleA[_MAX_PATH];
_wcstombsz(szTitleA, szTitle, _countof(szTitleA));
#endif
MapiFileDesc *fileDesc;
int num_attachments = 1 ;
if (DatasetType == TYPE_DATASET)
{
fileDesc = new MapiFileDesc ;
}
else
{
fileDesc = new MapiFileDesc[1 + mpntr->no_in_use] ;
num_attachments = 1 + mpntr->no_in_use ;;
}
memset(fileDesc, 0, sizeof(MapiFileDesc) * num_attachments);
fileDesc[0].nPosition = (ULONG)-1;
char szPathAM[MAX_DATASETS_PER_MULTI][_MAX_PATH];
char szTitleAM[MAX_DATASETS_PER_MULTI][_MAX_PATH];
#ifdef _UNICODE
fileDesc[0].lpszPathName = szTempNameA;
fileDesc[0].lpszFileName = szTitleA;
#else
fileDesc[0].lpszPathName = szTempName;
fileDesc[0].lpszFileName = szTitle;
#endif
if (DatasetType == TYPE_MULTISET)
{
for (int i = 0 ; i < mpntr->no_in_use ; i++)
{
fileDesc[i + 1].nPosition = (ULONG)-1 ;
#ifdef _UNICODE
CString temp_string ;
temp_string = mpntr->pntr[i]->m_Path + "\\" + mpntr->pntr[i]->m_Filename ;
_wcstombsz(szPathAM[i], temp_string, _countof(temp_string));
_wcstombsz(szTitleAM[i], mpntr->pntr[i]->m_Filename, _countof(mpntr->pntr[i]->m_Filename));
fileDesc[i + 1].lpszPathName = szPathAM[i] ;
fileDesc[i + 1].lpszFileName = szTitleAM[i] ;
#else
sprintf(szPathAM[i], "%s\\%s", mpntr->pntr[i]->m_Path, mpntr->pntr[i]->m_Filename) ;
sprintf(szTitleAM[i], "%s", mpntr->pntr[i]->m_Filename) ;
fileDesc[i + 1].lpszPathName = szPathAM[i] ;
fileDesc[i + 1].lpszFileName =szTitleAM[i] ;
#endif
}
}
MapiMessage message;
memset(&message, 0, sizeof(message));
message.nFileCount = num_attachments;
message.lpFiles = fileDesc;
AfxGetApp()->EnableModeless(FALSE);
HWND hWndTop;
CWnd* pParentWnd = CWnd::GetSafeOwner(NULL, &hWndTop);
pParentWnd->SetCapture();
::SetFocus(NULL);
pParentWnd->m_nFlags |= WF_STAYDISABLED;
int nError = lpfnSendMail(0, (ULONG)pParentWnd->GetSafeHwnd(),
&message, MAPI_LOGON_UI|MAPI_DIALOG, 0);
::ReleaseCapture();
pParentWnd->m_nFlags &= ~WF_STAYDISABLED;
pParentWnd->EnableWindow(TRUE);
::SetActiveWindow(NULL);
pParentWnd->SetActiveWindow();
pParentWnd->SetFocus();
if (hWndTop != NULL)
::EnableWindow(hWndTop, TRUE);
AfxGetApp()->EnableModeless(TRUE);
if (nError != SUCCESS_SUCCESS &&
nError != MAPI_USER_ABORT && nError != MAPI_E_LOGIN_FAILURE)
{
AfxMessageBox(AFX_IDP_FAILED_MAPI_SEND);
}
delete []fileDesc ;
if (bRemoveTemp)
CFile::Remove(szTempName);
}
Not sure if it will help out.
Roger Allen the man
|
|
|
|
|
Here is a class that can en/decode Base64...
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
|
Hi,
I have to solution in my project. Use CListView or MSFlexGrid.
The project is to display a automation in execution.
My problem is How can I do for to do this :
1/ I have 10 playlist. Each playlist have 1, 2 or 3 functions.
=> I would like to display each playlist with a color. So, if one function -> One line, if two functions -> two lines , ...
2/ I would like to design a rectangle for distinging the playlist in the automation
So, if anyone can help me.
Best regards
youssef
|
|
|
|
|