|
My collegue have ported some Project from Unix enviornment to windows enviornment.
Here is What i found in unistd.h
#ifndef _UNISTD_H
#define _UNISTD_H
#include <io.h>
#include <process.h>
#endif /* _UNISTD_H */
[Vote One Here, Complete my Survey....]
Alok Gupta visit me at http://www.thisisalok.tk
"I Think Believe this Will Help"
|
|
|
|
|
Well i was interested in the code i sent before as it was running in unix but it is possible run it on windows platform. I wanted to use that code somewhere in one of my programs
Any help pliz
-oam-
|
|
|
|
|
Christian Graus wrote:
A header file describes functionality that needs to be provided either in matching .cpp files, or in a library file.
True, but not always. Some of them have typedef and struct declarations only. I've no idea what mpapeo is looking for, however.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
DavidCrow wrote:
Some of them have typedef and struct declarations only
Yeah, and some contain the entire class ( can't they ? ). I said as much before, but in restating it, I was less careful
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
I've generally found that you can just delete this line and it will work under Windows. Don't quote me on that though, it may not work at all.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Hello, I'm parsing an XML on a deskband client using SAX: Here is the code:
<br />
CoInitialize(NULL); <br />
ISAXXMLReader* pRdr = NULL;<br />
<br />
HRESULT hr = CoCreateInstance(__uuidof(SAXXMLReader), NULL, CLSCTX_ALL,<br />
__uuidof(ISAXXMLReader), (void **)&pRdr);<br />
<br />
if(!FAILED(hr)) <br />
{<br />
hr = pRdr->putContentHandler(&m_whizzWnd->m_whizzHandler);<br />
<br />
VARIANT var;<br />
VariantInit(&var);<br />
V_BSTR(&var) = SysAllocString(wresp.c_str());<br />
V_VT(&var) = VT_BSTR;<br />
<br />
hr = pRdr->parse(var);<br />
<br />
VariantClear(&var);<br />
<br />
pRdr->Release();<br />
} else {<br />
MessageBox(NULL, TEXT("Error"), NULL, MB_ICONASTERISK);<br />
}<br />
<br />
CoUninitialize();<br />
The problem is that I have reports of memory leaks generated by that code. I'm detecting the memory leaks with the following code after the last include in all my cpp files:
<br />
#include <crtdbg.h><br />
<br />
#ifdef _DEBUG<br />
#define new new(_NORMAL_BLOCK, THIS_FILE, __LINE__)<br />
#undef THIS_FILE<br />
static char THIS_FILE[] = __FILE__;<br />
#endif<br />
And with the following class (I create an instance to begin test and get a memory leak report when the instance is deleted).
<br />
class FindMemoryLeaks<br />
{<br />
_CrtMemState m_checkpoint;<br />
public:<br />
<br />
FindMemoryLeaks()<br />
{<br />
_CrtMemCheckpoint(&m_checkpoint);<br />
};<br />
<br />
~FindMemoryLeaks()<br />
{<br />
_CrtMemState checkpoint;<br />
_CrtMemCheckpoint(&checkpoint);<br />
_CrtMemState diff;<br />
_CrtMemDifference(&diff, &m_checkpoint, &checkpoint);<br />
_CrtMemDumpStatistics(&diff);<br />
_CrtMemDumpAllObjectsSince(&diff);<br />
};<br />
};<br />
Any way, I have two kinds of memory leaks reports, the nice ones (no problem because I have file/line number)
<br />
Data: << r e s p o n s > 3C 00 72 00 65 00 73 00 70 00 6F 00 6E 00 73 00 <br />
c:\eclipse\workspace\gxclientcpp\gxclientcpp\gxclient\deskband\cwhizzmanager.cpp(348) : {267} normal block at 0x00D97FE0, 4 bytes long.<br />
And the ugly ones, because they DON'T report file/line number :
<br />
Data: <A 5 0 0 p l u s > 41 00 35 00 30 00 30 00 70 00 6C 00 75 00 73 00 <br />
{460} normal block at 0x00D9F5F8, 32 bytes long.<br />
The funny thing is that the A500plus comes in a character and in an attribute of an XML tag
The Content handler seems to be ok:
<br />
void MyContent::GetSafeValue(wstring &target, ISAXAttributes *attrs, LPTSTR name) {<br />
size_t len1;<br />
int len2;<br />
StringCchLength(name, STRSAFE_MAX_CCH, &len1);<br />
LPTSTR value;<br />
<br />
if (attrs->getValueFromQName(name, len1, &value, &len2) == E_INVALIDARG) {<br />
target = TEXT("");<br />
} else {<br />
target = value;<br />
SysFreeString(value);<br />
}<br />
}<br />
<br />
HRESULT STDMETHODCALLTYPE MyContent::startElement(wchar_t __RPC_FAR *pwchNamespaceUri,<br />
int cchNamespaceUri, wchar_t __RPC_FAR *pwchLocalName,<br />
int cchLocalName, wchar_t __RPC_FAR *pwchRawName,<br />
int cchRawName, ISAXAttributes __RPC_FAR *pAttributes)<br />
{<br />
m_characters.clear();
<br />
if (!wcscmp(pwchRawName, TEXT("response"))) {<br />
wstring boolStr;<br />
<br />
GetSafeValue(boolStr, pAttributes, TEXT("hasPrev"));<br />
<br />
if (!wcscmp(boolStr.c_str(), TEXT("true"))) {<br />
m_hasPrev = TRUE;<br />
} else {<br />
m_hasPrev = FALSE;<br />
}<br />
<br />
GetSafeValue(boolStr, pAttributes, TEXT("hasNext"));<br />
<br />
if (!wcscmp(boolStr.c_str(), TEXT("true"))) {<br />
m_hasNext = TRUE;<br />
} else {<br />
m_hasNext = FALSE;<br />
}<br />
}<br />
return S_OK;<br />
}<br />
<br />
HRESULT STDMETHODCALLTYPE MyContent::characters(wchar_t __RPC_FAR *pwchChars, int cchChars)<br />
{<br />
wstring aux(pwchChars);<br />
m_characters.append(aux.substr(0, cchChars));<br />
return S_OK;<br />
}<br />
Believe me, there seems to be nothing extrange there (no more than the GetSafeValue), and there are no obvious memory leaks (And the file is a little big to post it here)
If any one sees the mistake I would be grateful for ever
Regards, Demián
|
|
|
|
|
I have a small function in my app that displays an HTML dialog that works find in Windows XP but not 98. Code is as follows:
<br />
void ShowExportTemplatePreview(HWND hwnd)<br />
{<br />
<br />
HINSTANCE hinstMSHTML = LoadLibrary(TEXT("MSHTML.DLL"));<br />
<br />
if(hinstMSHTML)<br />
{<br />
SHOWHTMLDIALOGFN *pfnShowHTMLDialog;<br />
pfnShowHTMLDialog = (SHOWHTMLDIALOGFN*) GetProcAddress(hinstMSHTML, TEXT("ShowHTMLDialog"));<br />
<br />
if(pfnShowHTMLDialog)<br />
{<br />
char szTemplatePreview[MAX_PATH];<br />
wsprintf(szTemplatePreview, "%s\\Temp_0.html", cStartupData.szAppDirectory);<br />
<br />
WCHAR wcTemplatePreview[MAX_PATH];<br />
<br />
MultiByteToWideChar(CP_THREAD_ACP, NULL, szTemplatePreview, sizeof(szTemplatePreview), <br />
wcTemplatePreview, MAX_PATH);<br />
<br />
IMoniker *pURLMoniker;<br />
CreateURLMoniker(NULL, wcTemplatePreview, &pURLMoniker);<br />
<br />
if (pURLMoniker)<br />
{<br />
BSTR bstrOptions = SysAllocString(L"dialogHeight:30;dialogWidth:45;resizable:yes");<br />
<br />
(*pfnShowHTMLDialog)(hwnd, pURLMoniker, NULL, (char*) bstrOptions, NULL);<br />
<br />
SysFreeString(bstrOptions);<br />
<br />
pURLMoniker->Release();<br />
}<br />
}<br />
<br />
FreeLibrary(hinstMSHTML);<br />
}<br />
}<br />
This is mostly copied from MSDN and I am trying to find compatibility issues with no success. We have pinpointed the problem to:
(*pfnShowHTMLDialog)(hwnd, pURLMoniker, NULL, (char*) bstrOptions, NULL);
But i have no idea as to what is causing the error or how to even go about solving it. Does anyone have any experience with this function that could be of help? Thanks in advance.
|
|
|
|
|
You haven't said what the error is?
georgiek50 wrote:
We have pinpointed the problem to:
What problem - besides "not working"?
You aren't testing a) if the file exists, b) whether an appropriate version of MSHTML is being used, c) what ShowHTMLDialog() returns, d) whether the hWnd is valid.
FYI you should use the pre and code links on the Formatting bar below the mssage area when posting code.
Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
|
|
|
|
|
GetLastError() returns 0 and I don't know specifically which function to call to get this type of error (I'm very new to this stuff and can't find it in MSDN)
Not working means the dialog isn't opening. The file is there, MSHTML.dll is being loaded as well.
Thanks for the help.
|
|
|
|
|
|
Check your return values and init your pointers to NULL. Specifically, if CreateURLMoniker() fails, you don't look at its retval and pMoniker will be left as uninitialized (but non-zero) garbage, which you will treat as success.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ
Strange things are afoot at the U+004B U+20DD
|
|
|
|
|
CreateURLMoniker returns S_OK. The only reason I know that it is failing at the specific line is that the HRESULT returned by ShowHTMLDialog != S_OK (I have tested all other return values). I guess the most important question from here is to find what error code exactly the function returns. That is what I can't find documentation on.
Thanks for the help.
|
|
|
|
|
I have a tree containing a large number of items, each leaf item has a PARAM attached to it ( pointer to its data )
Is there a better way to highlight items in the tree than just looping thru all items in it ?
for example, I have something like (pseudo code):
...
for ( myData; ++myData )
{
tree.highlightItem( myData, TVI_ROOT );
}
...
myTree::highlightItem( myDataType myData, HTREEITEM hItem );
{
HTREEITEM hCurrent = hItem;
while( hCurrent )
{
HTREEITEM hChild = GetChildItem( hCurrent );
myDataType* pData = (myDataType*)GetItemData( hCurrent );
if ( pData == myData )
{
SetItemState( hCurrent, TVIS_SELECTED, TVIS_SELECTED );
}
if( highlightItem( hChild, myData ) )
return true;
hCurrent = GetNextItem( hCurrent, TVGN_NEXT );
}
}
I can set the root item as close as possible to the leaf I'm looking for, eliminating as much recursion as possible, but if a sub-tree contains a very large amount of items,
Is there a better solution ?
Thanks.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
I would have thought iterating the (MS) tree would be too slow and isn't something you would typically want to do. Why not keep a pointer to the selected node in your mydata struct/class. Then no lookups are needed. You do however need to ensure the tree and your mydata are kept in sync.
IMO this is one of big problems using many MS controls as you need to double up on where data is stored and transfer stuff back and forth. It is far better if the control simply displays your data wherever and however it is stored. But I diverse.
The MS Tree Ctrl isn't all that fast, especially with large trees. Which is why I don't use it.
Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
|
|
|
|
|
Neville Franks wrote:
Why not keep a pointer to the selected node in your mydata struct/class. Then no lookups are needed. You do however need to ensure the tree and your mydata are kept in sync.
I tried this, it works when the tree gets updated when the selected state of data is modified external of thh tree, but I have problems when changing the select items from within the tree itself.
Will keep trying to find what wrong with this.
Thanks.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Hi,
I have a fairly large application (maybe 100-200K LOC or so), and the resources have been divided up into several sections depending on their role in the project. Lately (after we switched to Visual Studio .NET 2003) we've been experiencing problems with a single part of the resources (defined in a separate .rc file). I.e. no resources defined in this single file will get compiled into the application in release mode. Everything works fine in debug mode. This includes all resources; menus, bitmaps, string tables etc.
Has anyone had any similar problems? Any hints?
Best regards,
Daníel
Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!
|
|
|
|
|
hello friends
plz tell me that how i can write in a text file from a buffer. and how i can search text file offset so that while writing in a file it shld not rewrite in the same position but it shld write in the position specified.
thanx
|
|
|
|
|
Add ur header:
<br />
#include "fstream.h"<br />
To write to File "Title.txt", at end of file.
<br />
ofstream a_file ( "Title.txt", ios::ate, ios::app);<br />
a_file<< "Data";<br />
a_file.close();<br />
To read from File "Title.txt"
<br />
char idata[256];<br />
ifstream b_file ( "Title.txt" );<br />
while (! b_file.eof() )
{<br />
b_file.getline(idata,256);<br />
cout<< idata <<endl;
}<br />
Hope it Helps... Replace the "Title.Txt" or "Data" with a variable and dont use the ""'s and you can have it set by user. Does this help?
/* Just a Human Trying to Live in a Computers World. */
|
|
|
|
|
do i have to encrypt files by hand then send them through a ftp connection, or is there a special protocol that deals with this? what i want is my program to have some type of protection during it's path to an FTP server (sniffer protection mainly i'm on a LAN )
thx in advance
|
|
|
|
|
Do some research on SSL type FTP connections.. I think I have seen articles here on CodeProject
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
I have a group of Buttons which I create at runtime. What I need to be able to do is add a ScrollBar to my form, which hides\shows the buttons that are in or out of my scrollable area. I have created a CScrollBar at runtime, but cannot generate a Message Handler to handle the scrolling. With the Buttons, I used ON_CONTROL_RANGE to specify the individual button ID, and do whatever I wanted with it. However I cant get a similar thing to work with my ScrollBar. Long winded description I know, just wondered if anybody had experienced anything similar.
|
|
|
|
|
Scroll bars send WM_HSCROLL or WM_VSCROLL messages to it's parent window.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
Hi,
I want to calculate the used disk space for a particular folder or the given path. In my knowledge two API's avilable in VC++.
1. GetDiskFreeSpaceEx
2. using LPWIN32_FIND_DATA (FindFirstFile, FindNextFile)
if we use GetDiskFreeSpaceEx, it gives the root directory space only.
Suppose i want to calculate the used space in F:\xx\yy\zz means i have to use
recursive search for all the subfolders using FindFirstFile, FindNextFile and calculate the used space using LPWIN32_FIND_DATA structure. It takes more time.
Is there any other option avilable to get the directory space immediately.
Like Any Folder -> Right click -> Properties --- The windows give quick result. Windows also using some searching concept but they done quickly, I think they updated the information every time somewhere it may be registry or Shell.
Is anybody having any idea about ... plz write...........
Your valuable suggestions are always welcome ......
Regards,
inbha.
|
|
|
|
|
inbha wrote:
if we use GetDiskFreeSpaceEx, it gives the root directory space only.
Actually it reports the size of the volume.
inbha wrote:
Suppose i want to calculate the used space in F:\xx\yy\zz means i have to use
recursive search for all the subfolders using FindFirstFile, FindNextFile and calculate the used space using LPWIN32_FIND_DATA structure. It takes more time.
True.
inbha wrote:
Is there any other option avilable to get the directory space immediately.
None to my knowledge.
inbha wrote:
Like Any Folder -> Right click -> Properties --- The windows give quick result. Windows also using some searching concept but they done quickly,
Depending on the number of files and folders encountered, it can take several seconds and you can see the numbers incrementing as it goes.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
I want to do something similar to Windows 2k's "Search for Files and Folders". Anybody know how it's done? Is it done with CScrollView with CEdit/CButton? How would I go about give CEdit box a 3d look? And get CButton to run?
|
|
|
|
|