|
Hi all,
I need to create a short cut to a folder in my VC++ project.
But failed when use the following code
when create a short cut to a file this code work ok.
then how to create a short cut to a folder?
I couldn't find more documents.
Thanks for help.
//////////////////////////////////////
{
HRESULT hResult;
IShellLink * pShellLink;
IPersistFile * pPersistFile;
wchar_t SaveLinkName[MAX_PATH];
::CoInitialize(NULL);
hResult=::CoCreateInstance(CLSID_ShellLink,NULL,CLSCTX_INPROC_SERVER,
IID_IShellLink, (LPVOID FAR*)&pShellLink);
if (SUCCEEDED(hResult))
{
pShellLink->SetDescription(lpDescription);
pShellLink->SetPath(LinkedFileName);
hResult = pShellLink->QueryInterface(IID_IPersistFile,(LPVOID*)&pPersistFile);
if(SUCCEEDED(hResult))
{
MultiByteToWideChar(CP_ACP,0,LinkFileName,-1,SaveLinkName,MAX_PATH);
hResult=pPersistFile->Save(SaveLinkName, TRUE);
pPersistFile->Release();
}
pShellLink->Release();
}
::CoUninitialize();
return hResult;
}
|
|
|
|
|
Hi
I would like to know how to add text to an edit box from a menu link.
I mean... Just like in a HTML Editor. When you click for example, on 'Tags > <br>', this would add the tag <br> where's your cursor at, in your Edit Box.
I would like to have the code for this, because I need it for a project.
All I found, from now on is to store the data into a variable and Set the Window's text to this variable (which is all the text), plus the tag.
You know what that does. It simply adds the tag to the end of my editbox, and I want it at my cursor's position.
Thanks a lot
|
|
|
|
|
have you tried this?
do a SetSel(pos, pos) to position the insert, then use ReplaceSel("<br>") to insert the text
-c
Though the cough, hough and hiccough so unsought would plough me through,
enough that I o'er life's dark lough my thorough course pursue.
--Stuart Kidd
|
|
|
|
|
Are you the same guy who's struggling with CEdit::ReplaceSel?
Tomasz Sowinski -- http://www.shooltz.com
"Yields falsehood when preceded by its quotation" yields falsehood when preceded by its quotation.
|
|
|
|
|
Thanks Chris.
Tomasz, I don't know who you're talking of.
|
|
|
|
|
If I got a lot of text in my EditBox, I won't get the <br> tag at the same position than if I have just like 5 lines of HTML code, am I right?
|
|
|
|
|
Hi,
there are days...
well, it works but I think there should be a better way of doing it.
my problem's like this :
I'm passing an array of char (cArray[50][20]) to a function which is declared as MyFunc(char *pArray).
with pArray I'd like to access the array-items, which it does if I increment it by 20, but then it only gives me the first character of each array-item. To correct this, I use strcpy(..) and all goes fine, but to me it looks like a really bad solution.
Someone has an idea to improve this ?
thanks
|
|
|
|
|
Typedef char [50] as a custom type (eg: MyArrayType ) and declare the function argument of type MyArrayType * .
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
And here we go again :
typedef char[50] cArrayType; gives a compile-error.
nontheless thanks
|
|
|
|
|
can you use a CStringArray, or a vector of CStrings?
Though the cough, hough and hiccough so unsought would plough me through,
enough that I o'er life's dark lough my thorough course pursue.
--Stuart Kidd
|
|
|
|
|
thanks for the reply.
the char-array items come from SQLBindCol(....) which wants type char. since
the database-table is about 40 fields large, I use the char array.
After getting all the items filled, I could of course write then to a CString-array but that looks as bad to me as what I've right now.
there should be a way to access the array be incrementing the pointer one step
at a time.
|
|
|
|
|
typedef char cArrayType[50];
Tomasz Sowinski -- http://www.shooltz.com
"Yields falsehood when preceded by its quotation" yields falsehood when preceded by its quotation.
|
|
|
|
|
Great !
almost correct, but it must be cArrayType[20]
and now it works like I want it to.
thanks
|
|
|
|
|
Sorry, I assumed you knew what I meant. Try this:
typedef char MyArrayType [50];
MyArrayType myArray [20]; /ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
All-
I just joined this site, because when I get error messages I am often pointed to it during a search. But, I am a virgin when it comes to code. I am getting an error "cannot initialize ressource.dll". I have not installed anything but have lost most of my right-click menu and that error will appear ONCE during every DIFFERENT action. For example: Drag & Drop error, click close and Drag & Drop works without a problem. But, if I get that error with another action AFTER Drag & Drop, then it will reappear the next time I try to drag & Drop.
I do not have ressource.dll on my system and wouldn't know what program it belongs to.
I want to "ease" my way into being able to do simple debugging and I hope this will be the place.
Thanks in advance Mike Mc
|
|
|
|
|
Problem Solved. I had a shell compression program called Iceows (formerly ARJ Folder). I had disabled the commands and that was what caused ALL of my problems.
But, here's the kicker. The error was "Cannot Initialize ressource.dll" and this program doesn't install it.
Now, I should be able to just uninstall the p[rogram completely.
Then I can lurk and learn. My 4th system and I cannot keep up with the latest codes.
Mike Mc
|
|
|
|
|
I got a sample Dialog based MFC program. I made some modifications to it, one of them is: when F1 is pressed, show the HTML help file. But when I run it, after the HTML help file was shown, a message box pop up with caption of "Windows Help", and the message itself is:
"Cannot find the S:\TRANSFER\lwang\Antialiasing\Debug\ASIST3D.HLP file. Do you want to try to find this file yourself? Yes No".
It seemed to me that the default function for accelerator key "F1" is still being invoked somewhere in the program. How can I get rid of it?
Thank you very much for any hint!
|
|
|
|
|
Have you checked the message map? Probably that - unless that's how you made your mod?
Dylan Kenneally
London, UK
|
|
|
|
|
hmm, there is a default function for ID_HELP in the App class. Getting rid of that line solves this problem. Thanks!
|
|
|
|
|
MFC translates F1 into ID_HELP command. You're invoking Html help in response to what event?
Tomasz Sowinski -- http://www.shooltz.com
"Yields falsehood when preceded by its quotation" yields falsehood when preceded by its quotation.
|
|
|
|
|
Thanks for the fast response. I'm invoking Html Help in response to menu item File->Keys. And I assign F1 as the accelerator key to this menu item.
I add the following lines to my dialog cpp in its message map declaration:
ON_COMMAND(ID_HELP, OnFileKeys)
And remove the line for ID_HELP in the App class.
Thus solved the problem.
Thank you very much again!
|
|
|
|
|
is it possible to use the RASDial Function without knowing the
szEntryName + password + username, and just connect with the
default settings to redial a lost Modem connection .
thanks
|
|
|
|
|
|
According to my experiences and some sources on the net the MFC class CSocket does not seem to be very thread-safe.
Creating the sockets (listen sockets & accepted sockets) in the main-thread and using them in another thread gives troubles...
So I tried to create all sockets in the thread function.
After calling AfxSocketInit() in the thread function (I don't know if this is correct ...) Everything seems to be fine, But the virtual functions OnAccept(), OnReceive(), ... are not called.
The attach/detach trick is not an option, because both mainthread and other thread use the sockets.
How should I handle this problem ?
Any help appreciated.
Greetings,
Niko
|
|
|
|
|
Why can you not use Attach/Detach? I use this in a multi-threaded socket app.
e.g. I have a thread that uses a socket that listens on a port. When an incoming connection arrives it creates a new thread and passes the thread the socket handle:
void CListenSocket::OnAccept(int nErrorCode)
{
CSocket socket;
Accept(socket);
CAcceptThread* pThread = (CAcceptThread*)AfxBeginThread(
RUNTIME_CLASS(CAcceptThread),
THREAD_PRIORITY_NORMAL,
0,
CREATE_SUSPENDED);
pThread->m_hSocket = socket.Detach();
pThread->ResumeThread();
}
BOOL CAcceptThread::InitInstance()
{
m_pSocket = new CServiceClientSocket;
m_pSocket->Attach(m_hSocket);
}
Faith. Believing in something you *know* isn't true.
|
|
|
|