|
|
#include <sys/types.h>
#include <sys/dir.h>
#include <sys/param.h>
#include <stdio.h>
#define FALSE 0
#define TRUE !FALSE
extern int alphasort();
char pathname[MAXPATHLEN];
main() { int count,i;
struct direct **files;
int file_select();
if (getwd(pathname) == NULL )
{ printf("Error getting path\n");
exit(0);
}
printf("Current Working Directory = %s\n",pathname);
count =
scandir(pathname, &files, file_select, alphasort);
if (count <= 0)
{ printf("No files in this directory\n");
exit(0);
}
printf("Number of files = %d\n",count);
for (i=1;i<count+1;++i)
printf("\n%s\n ",files[i-1]->d_name);
printf("\n");
}
int file_select(struct direct *entry)
{ char *ptr;
char *rindex(char *s, char c);
if ((strcmp(entry->d_name, ".") == 0) ||
(strcmp(entry->d_name, "..") == 0))
return (FALSE);
ptr = rindex(entry->d_name, '.');
if ((ptr != NULL) &&
((strcmp(ptr, ".c") == 0) ||
(strcmp(ptr, ".txt") == 0) ||
(strcmp(ptr, ".m") == 0) ))
return (TRUE);
else
return (FALSE);
}
debina
|
|
|
|
|
the output is displaying file and folder from desktop but i want to display the file inside the folder with specific extension...
|
|
|
|
|
|
I am not able to get you path means? but this program is displaying the file present in desktop..
|
|
|
|
|
What is the full directory path that gets stored in pathname by the getwd function?
|
|
|
|
|
|
Well that seems clear. How exactly do you think that using that path for your scandir will return files from a different folder?
|
|
|
|
|
Actually that was my problem of not working with different location ...that y I uploaded to find solution over here..
|
|
|
|
|
I don't see a problem; you get the path of the desktop and list the files in it. If you want to list the files of a different folder then get the correct path for the folder in question. And don't use getwd (or getcwd ) unless you are certain that you are rooted in the correct directory to start with. Use a different method to select the folder you wish to list.
|
|
|
|
|
thank you ...counted I will kip in mind...
|
|
|
|
|
With visual studio 6 you were able to delete the .clw file to re-build the class wizard if you made a lot of changes in the source files and that were not showing in the class wizard.
How do you do this with VS 2010 - there is no longer a .clw file.
|
|
|
|
|
|
I want to update the database based on triggers . I need the database to get updated automatically based on already written code.I do not want to manually execute queries to update the database
|
|
|
|
|
So what is your question?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
|
If you have a CMFCShellListCtrl..........CListCtrl with multiple selections?
|
|
|
|
|
Hey guys,
I'm encountering the following problem. I wolud very much appreciate your help.
Description of the problem
MFC Desktop Application
VisualStudio 2010
Icons are supposed to be displayed in a CListCtrl as a CImageList.
It usually works fine except when using RemoteDesktop with the OS Windows 2008 / 2003.
In these particular cases the icons are just displayed as a black square.
Connecting with VMware vSphere (alternative to RemoteDesktop) -> Icons are shown appropriately
Remotdesktop on Windows XP / 7 / 8 -> Icons are shown appropriately
Code:
OnInitDialog()
{
/*
~Standardcode
*/
// Setting the symbol for this dialog-field. This is done automatically
// if the mainwindow of the application is no dialog-field.
SetIcon(m_hIcon, TRUE); // using big symbol
SetIcon(m_hIcon, FALSE); // using small symbol
// TODO: appending additional initialization
InitList(); //
m_list.SetImageList(imageList, LVSIL_NORMAL);
//captions
CString buf = _T("testitem");
m_list.InsertItem(0, buf, 0);
m_list.SetItemData(0, (DWORD) 0);
m_list.SetItemText(0, 0, _T("0"));
m_list.SetItemState(0, 2, LVIS_SELECTED);
m_list.EnsureVisible(0, FALSE);
}
void CDispomarkierungTestDlg::InitList()
{
imageList = new CImageList();
int err = imageList->Create(16, 16, ILC_COLOR32 | ILC_MASK, 1, 1); //ILC_COLOR16 , ILC_COLOR8 , ... getested
int id = 40;
int requiredLength = 3154;
LPCSTR picInCharsFromDB = GetBitmapAsText();
int width = 24;
int heigth = 24;
int pixel = 32;
int planes = 1;
BYTE *picInBytes = new BYTE[requiredLength];
int lengthVariable = requiredLength;
int* lengthPointer;
lengthPointer = &lengthVariable;
Base64Decode(picInCharsFromDB, requiredLength, picInBytes, lengthPointer);
HANDLE hBitMap = CreateBitmap(width, heigth, planes, pixel, picInBytes);
BITMAP bitmap;
GetObject(hBitMap,sizeof(BITMAP),&bitmap);
CImage image;
image.Attach((HBITMAP)hBitMap);
CBitmap icon;
icon.Attach((HBITMAP)hBitMap);
CBitmap* bitmappointer;
bitmappointer = &icon;
BITMAP bmp;
icon.GetBitmap(&bmp);
CClientDC dcClient(this);
CDC memDC;
memDC.CreateCompatibleDC(&dcClient);
HBITMAP hbmMask = ::CreateCompatibleBitmap(memDC.GetSafeHdc(), width, heigth);
ICONINFO ii = {0};
ii.fIcon = TRUE;
ii.hbmColor = icon;
ii.hbmMask = hbmMask;
HICON hIcon = ::CreateIconIndirect(&ii);
::DeleteObject(hbmMask);
err = imageList->Add(hIcon);
}
In the real application, the source is a database which saves the Bitmap as a string. That’s the reason for the complicated code during the loading. Loading the images as a resource is possible, but in this case no option.
Drivers of server and client are updated to latest version.
I added the project here https://www.hidrive.strato.com/lnk/gRuMg38R. Thanks for helping out
|
|
|
|
|
From your explanation it's not clear whether Windows 2008 and 2003 represent the remote desktop, or the desktop on which you are viewing the remote desktop.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
They represent the remote desktop on which the application runs, sorry for the unclarity.
|
|
|
|
|
What does GetBitmapAsText(); do, are you sure it is returning the correct data?
|
|
|
|
|
Please don't bother about GetBitmapAsText(); because it only exists in the demo project in order to replace the complex algorithm and database infrastructure in the real project and make the problem portable. The correct loading of picture data from DB can be assumed because the problem is not that the picture can't be seen at all but that it can only be seen in certain circumstances.
|
|
|
|
|
APSAccounts wrote: complex algorithm and database infrastructure To load an icon?
APSAccounts wrote: is not that the picture can't be seen at all but that it can only be seen in certain circumstances. Well apart from the fact that it happens on some systems but not on some others, we have no real information to go on.
|
|
|
|
|
The demo project gives you the function GetBitmapAsText(); which constantly and reliably delivers the same picture because it always returns a hardcoded string of base64-encoded picture data. Despite of this fact and despite of the constant algorithm for the presentation the presentation of the picture differs depending on the system. Therefore, for me the reason for the problem is situated somewhere in the interaction of the presentation algorithm with the specific system.
The only bridge I could build for you in order to make the picture data more transparent, would be to get rid of the base64 encoding and hardcode the picture data directly into picInBytes (BYTE*) as it is consumed by the API function CreateBitmap. But would it really help?
The only reason for checking the picutre data once again would be for me the knowledge of a limitation saying that CreateBitmap needs the data on different systems in different forms...
|
|
|
|
|
APSAccounts wrote: the knowledge of a limitation saying that CreateBitmap needs the data on different systems in different forms... That is most unlikely, as it would affect half the systems across the world. You could always check that by looking at the documentation.
|
|
|
|