|
|
How can we check whether URL is Valid or not through a MFC Application?
|
|
|
|
|
PathIsURL() API
Refer MSDN
|
|
|
|
|
It is just checking URL is valid format or not, but what i want is whether the URL path is exixt or not. for example if we give www.goooggle.com, the i want to tell it is not valid...
|
|
|
|
|
The only way to tell is to try connecting to it.
|
|
|
|
|
Hi,
I have a string variable m_strAddBlob with value in it.I need to convert it to char * .
I do this way
char* buf = (char*)(LPCTSTR)m_strAddBlob;
//nBytes=m_strAddBlob.GetLength();
For checking whether the string is properly typecasted or not I do the following....
CString str(buf);
AfxMessageBox(str);
then I get only first character of the string.
Any Suggestions would be great help.
Thanks
Today is a gift, that's why it is called the present.
|
|
|
|
|
Use CString::GetBuffer()
Nobody can give you wiser advice than yourself. - Cicero
|
|
|
|
|
A conversion like
char * buf = (char *)(LPCTSTR)m_strAddBlob;
is not correct in case of Unicode strings -- the result looks like a string consisting of the first character only.
I think you first have to convert your string from Unicode to Ansi. In new MFC this can be done like this:
CStringA ansi(m_strAddBlob);
Then if you actually need a pointer to constant string, then you can use explicit cast:
const char * buff = ansi;
If you realy need a pointer to non-constant string and modify the string, then use GetBuffer and ReleaseBuffer functions:
char * buff = ansi.GetBuffer();
. . .
ansi.ReleaseBuffer();
I hope this helps.
|
|
|
|
|
Why return type is not become part of functions signature.
|
|
|
|
|
Because you cannot differenciate a function by its return type. Your compiler will throw you an error if you have to identical functions that differ only by the return type (it's impossible for him to know wich one needs to be used).
And as function signatures are used to differentiate different overloaded functions, it has no use in the signature.
|
|
|
|
|
hi
I want my application to display menus,messages and captions in marathi.
abbmmm
|
|
|
|
|
What is that you are using to build your application? VC 6 or Above? If VC6, is your application unicode aware? Have you localised your computer with Indic script?
Nobody can give you wiser advice than yourself. - Cicero
|
|
|
|
|
I have a large data array and was told to make it static to ensure that I have enough storage allocated
DATA_DETAILS signal_details[NO_FIELDS] = {
"1.000000",
"Integer",
"0",
"0",
etc
Note NO_FIELDS could be 25,000 and some of the elements are char arrays of 4096 bytes. i.e. lots of data.
Now if I make it static; e.g.
static DATA_DETAILS signal_details[NO_FIELDS] = {
"1.000000",
"Integer",
"0",
"0",
etc
the project fails to build as I have extern references; e.g including the keyword static causes a problem.
extern static DATA_DETAILS signal_details[NO_FIELDS];
How can I overcome this problem please.
|
|
|
|
|
I think the static is for the case your array is declared locally in a function. If it is a global variable and is accessed from other modules, then do not add static (otherwise it becomes available from the current file only).
|
|
|
|
|
Why somebody did tell that?
You have not to make it static , since static means only file scope in such context.
You can choose to allocate storage on the stack or on the heap. You don't need to allocate static as you did.
|
|
|
|
|
When you were told to make it static, they probably meant it in the context of where you allocate it ( stack or heap ). If you use operator new with such a large struct there is a good change you will run out of memory, but declaring it on the stack, as it appears in your code, you are guaranteed to have the memory before you run your exe.
|
|
|
|
|
|
static vars are not stored in the stack so in a way if you declare a var static, the memory is guaranteed for that var.
-Prakash
|
|
|
|
|
Mr.Prakash wrote: the memory is guaranteed for that var.
I think it holds for automatic vars too.
|
|
|
|
|
well static and extern do not o hand in hand.
but what abt the case when we have to make this structure visible to other files(declare extern) and also have guaranteed memory allocation assumin the structure is not local to any function. Is it that the allocatin shall be made on the stack for a function using it.
|
|
|
|
|
tom groezer wrote: Is it that the allocatin shall be made on the stack for a function using it.
Since the structure is declared in someother file, and used as extern in other files or function, the memory is still allocated to the structure, if the function is making a copy of the structure into its stack then its a different thing, but the original structure has been memory preallocated.
-Prakash
|
|
|
|
|
hi everyone,
I know, I already asked about that topic, but I still can't get it to work.
the problem was that i want the dialog opened by SHBrowseForFolder() to get opened on a specified folder.
here is the code i wrote :
void CFileRenamerDlg::OnBrowseFolder()
{
CoInitialize(NULL);
char folderBuf[MAX_PATH];
LPITEMIDLIST pidl = NULL;
BROWSEINFO bi;
bi.hwndOwner = this->GetSafeHwnd();
bi.pidlRoot = pidl;
bi.pszDisplayName = folderBuf;
bi.lpszTitle = _T("Select the folder where your files are located in...");
bi.ulFlags = BIF_NEWDIALOGSTYLE | BIF_RETURNONLYFSDIRS | BIF_SHAREABLE;
bi.lpfn = NULL;
pidl = SHBrowseForFolder(&bi);
if (pidl != NULL) {
SHGetPathFromIDList(pidl, folderBuf);
m_Directory.SetWindowText(folderBuf);
m_strFolder = folderBuf;
}
}
for your information, m_strFolder is declared as a CString .
this compiles fine, but always starts on the desktop. if I uncomment what is commented, the compiler (VC7.1) complains about the A2W() macro (actually, not directly the macro, but the "variables" used within).
did anybody already encountered this ?
can anyone suggest a better way (if any) to get SHBrowseForFolder() to get opened on a specified folder ?
thanks in advance.
|
|
|
|
|
super_ttd wrote: [...] the compiler (VC7.1) complains about the A2W() macro [...]
Try the newer improved CA2W macro. Actually I think you need CT2W macro. The correct shortest usage:
::SHParseDisplayName(CT2W(m_strFolder), . . .
Then try the rest of the code again. I hope this helps.
|
|
|
|
|
thanks for you answer. however, I have to add some more details.
actually, my A2W() was a mistake when I posted the message. I actually used T2W(), but not CT2W() because SHParseDisplayName() waits for a LPWSTR.
hum, not i'm checking the msdn and it tells me a LPCWSTR, but intellisense was telling LPWSTR. which to believe, and how to solve that ?
|
|
|
|
|
Since SHParseDisplayName requires LPCWSTR , the proposed solution should work:
::SHParseDisplayName(CT2W(m_strFolder), . . .);
|
|
|
|