|
Dears,
I´m trying to use createdirectory in visual c++ on a mfc application. I´m compiling this on .NET and i got a problem.
This function don´t run on windows 98 only in windows XP.
Some know how to solve this problem ?
Regards,
Luciano Fávaro
luc_favaro@yahoo.com.br
Luciano
|
|
|
|
|
|
This is the routine that i got a problem, it basiclly copy all files located in sPath to dPath.
The function CreateDirectory and CopyFile ar not running on windows98. I generated a log file and i discovered that on windows 98 the string dPath became invalid like:
original: "c:\teste"
garbage: "Y:\teste"
I read some articles and some of them indicate that the problem is Unicode conversion, but i try to follow the articles steps but it´s unusably.
One thing,
if in the function call CreateDirectory((LPCTSTR)dPath,NULL);
i change (LPCTSTR)dPath by a constant like "c:\\teste" the function run.
Please if you could help me, i´m thank,
LFávaro.
BOOL Cteste11Dlg::CreateTree(CString &sPath, CString &dPath)
{
CreateDirectory((LPCTSTR)dPath,NULL);
fstream f;
try
{
f.open("c:\\arq_log", ios::app);
// log para debug
// dt = _datetime_t::now();
//f << dt.fmt() << "DEBUG - Abriu arquivo de log\n";
}
catch (CFileException * pEx)
{
// log para debug
// dt = _datetime_t::now();
// f << dt.fmt() << "DEBUG - Ocorreu erro ao abrir arquivo\n";
TCHAR sz[1024];
pEx->GetErrorMessage(sz, 1024);
// log - erro gerado por excecao
// dt = _datetime_t::now();
//f << dt.fmt() << ERRO << sz;
pEx->Delete();
return FALSE;
}
f << "|" << (LPCTSTR)dPath << "|\n";
f.close();
CFileFind finder;
CString sWildCard = sPath + "\\*.*";
//CString sDestFile;
CFileFind finderDestFile;
BOOL bFound;
BOOL bWorking = finder.FindFile(sWildCard);
bFound = bWorking;
while (bWorking)
{
bWorking = finder.FindNextFile();
if (finder.IsDots())
continue;
if (finder.IsDirectory())
{
CString s = finder.GetFilePath();
CString temp=dPath+"\\"+finder.GetFileName()+"\\";
BSTR bstr2 = temp.AllocSysString();
BOOL a=CreateDirectoryW(bstr2,NULL);
DWORD d=GetLastError();
CreateTree(s,temp);
continue;
}
// copy files
if (CopyFile(finder.GetFilePath(),(dPath+"\\"+finder.GetFileName()), FALSE))
{
DWORD dwAttrs = GetFileAttributes(finder.GetFilePath());
if (!(dwAttrs & FILE_ATTRIBUTE_READONLY))
{
SetFileAttributes((dPath+"\\"+finder.GetFileName()),
dwAttrs | FILE_ATTRIBUTE_READONLY);
}
}
/*else
{
DWORD l=GetLastError();
MessageBox("Couldn't copy file.");
} */
}
return bFound;
}
LFávaro
|
|
|
|
|
luc_favaro wrote:
I generated a log file and i discovered that on windows 98 the string dPath became invalid like:
original: "c:\teste"
garbage: "Y:\teste"
Hmmm, this looks like you are overwriting memory somewhere, a bad pointer perhaps. The problem is not with CreateDirectory or CopyFile. If you corrupt the string that you pass to those functions, then obviously they will fail. Trace through your code and try and locate when the string that you pass gets corrupted.
Nish
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Review by Shog9
Click here for review[NW]
|
|
|
|
|
Hi folks..
I've created an activex control for a website that uses javascript to fetch data..
Now, the problem is that i can't manke that control DO anything even though the function is added to the project..
My question is HOW to create "PUBLIC" functions to use on my website..
This is what i'm using on the website..
<br />
<script><br />
<br />
function winamp() {<br />
<br />
myStr = MyControl.MyFunction;<br />
<br />
alert(myStr);<br />
<br />
return;<br />
}<br />
<br />
</script><br />
<br />
<br />
<OBJECT ID="MyControl" WIDTH=0 HEIGHT=0 CLASSID="CLSID:3BD88955-B9EB-4185-9F47-FEA07F6109B8"><br />
<PARAM NAME="_Version" VALUE="65536"><br />
<PARAM NAME="_ExtentX" VALUE="2646"><br />
<PARAM NAME="_ExtentY" VALUE="1323"><br />
<PARAM NAME="_StockProps" VALUE="0"><br />
</OBJECT><br />
<br />
This *SHOULD* give an alertbox - saying "Hello World".. but i get "Object not supported"
I really need some help!
|
|
|
|
|
In javascript, you neeed to use the parens when calling functions. Change your call to myStr = MyControl.MyFunction(); and see what happens.
Ron Ward
|
|
|
|
|
|
Are you certain your activex control is registered on your client machines and that the users have turned all the security options dealing with unsigned controls on from within IE? Because what you've done should work; assuming your GUID is a valid control on the client PCs. If the control is proplery constructed, you should be able to reference the .object variable:
if( MyControl.object == null )
alert('Control not found');
Ron Ward
|
|
|
|
|
Hello,
I want to start learn HOOK, but all the tutoials I see here, is in Visual C++ 6, I prefer to start directly from Visual C++.NET.
Where can I start?
Thank's,
Itay.
|
|
|
|
|
|
Hello
I need a view class that can show formatted text with pictures, tables and font colors in two columns (MSWord-like with text flowing from one column to another) with page divisions.
It can be read-only, but with copy operation support.
I was adviced that I can use PDF format in some way.
Can anyone help me with at least a starting point to look for info - some MFC classes, custom controls or articles and sites in inet?
Thank you in advance
|
|
|
|
|
Cant you execute MSWord?
Archigal wrote:
It can be read-only, but with copy operation support.
Copy and paste seems to rule out any pdf-renderer like ghostview.
Only copy may or may not work with pdf (rendering results in a graphic!)
Maybe the easiest would be generating HTML and starting an IE on it?
(You could even design your own XML-dialect and use XSLT to make HTML from it)
You have endless possibilities , but it seems what you want is a several weeks project requiring some degree of experience (or learning on the fly, extending the time).
< edit >RTF (rich text format) might help you. I am sure it can do columns, and a renderer should be somewhere in the web (OpenOffice?)< /edit >
Hope this has helped (and not shattered your dreams).
My opinions may have changed, but not the fact that I am right.
|
|
|
|
|
Hello,
how can i get the Geteway IP Address ( or List ) in a Windows NT system.
Thanxs
Marco
|
|
|
|
|
I'm trying to write a small program that shovels search parameters into Kazaa and then initiates a search. Almost a dynamic macro
I'm fairly new with Visual Basic and C++, and I while I understand basic DLL structure, I am confused as how I can control one program through another.
Any thoughts or ideas? I know I'm missing something.
|
|
|
|
|
If you want to do it for fun, do it, but if not (if you need it, try to download kazaalite 2.02 that includes that external utility)...
After having said that...
1. If kazaa gives you any DLL with some methods, you should use it.
2. If kazaa don't give you any DLL or OCX... you should intercept windows messages and throw the same (or other) messages to the application parts (I think...)
Hope this helps...
|
|
|
|
|
This is actually even pretty simple.
You search for the Kazaa window with FindWindow or EnumWindows .
Once you found the window, you search for the Kazaa client windows, namely the search edit field and search button with EnumChildWindows .
You enter the search text with SendMessage(wndSearchField, WM_SETTEXT, text, strlen(text)) and simulate a button press like that: SendMessage(::GetParent(wndButton),WM_COMMAND,MAKEWORD(::GetDlgCtrlID(wndButton),BN_CLICKED),(LPARAM)wndButton);
Hope this helps!
regards
Greg
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Hi all,
I'm traversing through a directory extracting information from files in it. I've noticed that the filelist seems to be sorted by name on windows NT, but is sorted by some other method on Windows 2000. Do you know anything about this? I'm using VS C++ 6.0 MFC to build my apps.
I really need to traverse the file list alphabetically, so is there a function out there where I can force the file list to be sorted alphabetically so my lists come out in the order they need to?
Thanks in Advance!
Dan Willis
|
|
|
|
|
FindFirstFile/FindNextFile do not guarantee any order
(probably the NT partition got defragged or sth like that lately, or maybe it's an "added goodie".)
So to play nice, you need to sort the stuff on your own.
So many people long for eternity that don't know what to do on a rainy sunday afternoon. [sighist] | [Agile Programming] [doxygen] If you look for evil in me you will find it whether it's there or not.
|
|
|
|
|
Sorta depends on what you mean by alphabetically.
For files which have numbers in their names and such,
I think that a lexical ordering is not usually
appropriate. I use a different comparator than std::less
for these kinds of things. (see below)
So if you want to process things in a more natural
order, use a collection class with a more
appropriate comparator.
struct MyLessC:binary_function<const char*,const char*,bool> {
bool operator()(const char* a,const char* b) const {
for (;; ) {
if (*a>='0'&&*a<='9') {
int _a=atoi(a);
while(*a>='0'&&*a<='9')
++a;
if (*b>='0'&&*b<='9') {
int _b=atoi(b);
while(*b>='0'&&*b<='9')
++b;
if (_a!=_b)
return _a<_b;
} else {
return *b>'9';
}
} else if (*b>='0'&&*b<='9') {
int _b=atoi(b);
while(*b>='0'&&*b<='9')
++b;
return *a<'0';
} else {
if (*a!=*b)
return *a<*b;
else if (*a)
++a,++b;
else
return false;
}
}
return false;
}
};
|
|
|
|
|
groover4life wrote:
I'm traversing through a directory extracting information from files in it. I've noticed that the filelist seems to be sorted by name on windows NT, but is sorted by some other method on Windows 2000.
I think you are dreaming this up - or more likely, you're mixing up FAT and NTFS.
NTFS is always kept in alphabetic order. That's an inherent property of it.
FAT is more like "thorow it in wherever there is space".
Btw, even if it's 5.0 (aka Windows 2000) or 5.1 (aka eXtreme Perversion), it's still Nice Try.
|
|
|
|
|
void COperDlg::OnButtonSave()
{
m_GridOper.UpdateData(true);
CTreeSet TreeSet;
TreeSet.m_strSort="indexs ASC";
if(!TreeSet.Open(CRecordset::snapshot,"tree"))
{
::AfxMessageBox("error!");
return;
}
int number=1,child;
CString str;
if((m_GridOper.GetRowCount()-1)<=num)
{
while(!TreeSet.IsEOF())
{
str.Format("%d",TreeSet.m_class);
if(m_GridOper.GetItemText(number,2)=="one")
child=1;
else
child=0;
if(m_GridOper.GetItemText(number,0)!=TreeSet.m_treename
||m_GridOper.GetItemText(number,1)!=str||m_GridOper.GetItemText(number,3)!=TreeSet.m_information
||child!=TreeSet.m_child)
{
TreeSet.Edit();
TreeSet.m_treename=m_GridOper.GetItemText(number,0);
TreeSet.m_class=atoi(str);
TreeSet.m_child=child;
TreeSet.m_information=m_GridOper.GetItemText(number,3);
TreeSet.m_indexs=number;
TreeSet.Update();
TreeSet.Requery();
}
number++;
TreeSet.MoveNext();
}
}
if((m_GridOper.GetRowCount()-1)>num)
{
while(!TreeSet.IsEOF())
{
str.Format("%d",TreeSet.m_class);
if(m_GridOper.GetItemText(number,2)=="one")
child=1;
else
child=0;
if(m_GridOper.GetItemText(number,0)!=TreeSet.m_treename
||m_GridOper.GetItemText(number,1)!=str||m_GridOper.GetItemText(number,3)!=TreeSet.m_information
||child!=TreeSet.m_child)
{
TreeSet.Edit();
TreeSet.m_treename=m_GridOper.GetItemText(number,0);
TreeSet.m_class=atoi(str);
TreeSet.m_child=child;
TreeSet.m_information=m_GridOper.GetItemText(number,3);
TreeSet.Update();
TreeSet.Requery();
}
number++;
TreeSet.MoveNext();
}
for(int i=0;i
|
|
|
|
|
Hi,
I created a small VC++ 6.0 application that creates a directory using the current time and date for the directory's name. This works fine.But then I want to copy files from another location into my directory, and CopyFile fails on me, with the error 'file not found'. Of course the file doesn't exist, since I'm trying to copy it into the newly created directory.
Any ideas?
n
|
|
|
|
|
|
hey....if file doesn't exist......how can you copy???
CopyFile() requires one file to exist to copy it to other.
C.R.Naik
|
|
|
|
|
We will have more than one EventMessageFiles and ParameterMessageFiles to get the description for some events.
I don't know how to use these files.
Please send me mail if anyone knows...
We will see the following default description if no message file is there in the registry.
"The description for Event ID ( Event ID) in Source ( Event Source ) cannot be found. The local computer may not have the necessary registry information or message DLL files to display messages from a remote computer. The following information is part of the event:"
How can I get this default description programatically..
Thanks in Advance,
Mittapalli
|
|
|
|