Click here to Skip to main content
15,898,222 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: CPreviewView Class Pin
PJ Arends4-Sep-05 21:32
professionalPJ Arends4-Sep-05 21:32 
GeneralRe: CPreviewView Class Pin
mikobi5-Sep-05 3:12
mikobi5-Sep-05 3:12 
GeneralRe: CPreviewView Class Pin
mikobi5-Sep-05 6:49
mikobi5-Sep-05 6:49 
QuestionRS232 problem Pin
transoft2-Sep-05 6:19
transoft2-Sep-05 6:19 
AnswerRe: RS232 problem Pin
Trollslayer2-Sep-05 6:21
mentorTrollslayer2-Sep-05 6:21 
GeneralRe: RS232 problem Pin
transoft2-Sep-05 6:35
transoft2-Sep-05 6:35 
GeneralRe: RS232 problem Pin
Ted Ferenc2-Sep-05 12:33
Ted Ferenc2-Sep-05 12:33 
QuestionSHChangeNotifyRegister notification Pin
ragavan2-Sep-05 4:54
ragavan2-Sep-05 4:54 
I have a sample application that is registering for the notification of the file-create . I am using SHChangeNotifyRegister API to get the notifcation . Since my appln is to be supported in 98/me i haved used this . But when i copy around 50 files .. .. I am getting notification of only 20 files .. .I have attached the code for your reference

Header file
#define WM_USER_MEDIACHANGED WM_USER+88

// For the Shell notifier, to indicate the type of events for which to receive
// notifications.
#define SHCNF_ACCEPT_INTERRUPTS 0x0001
#define SHCNF_ACCEPT_NON_INTERRUPTS 0x0002
#define SHCNRF_RecursiveInterrupt 0x1000

typedef struct {
DWORD dwItem1; // dwItem1 contains previous PIDL or name of the folder.
DWORD dwItem2; // dwItem2 contains the new PIDL or name of the folder.
} SHNOTIFYSTRUCT;


// Memeber Functions.
LRESULT CALLBACK WndProcedure(HWND hWnd, UINT uMsg,
WPARAM wParam, LPARAM lParam);

.cpp file
INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
MSG Msg;
HWND hWnd;
WNDCLASSEX WndClsEx;
ULONG l_ulSHChangeNotifyRegister;
const char *ClsName = "BasicApp";
const char *WndName = "A Simple Window";

// Create the application window
WndClsEx.cbSize = sizeof(WNDCLASSEX);
WndClsEx.style = CS_HREDRAW | CS_VREDRAW;
WndClsEx.lpfnWndProc = WndProcedure;
WndClsEx.cbClsExtra = 0;
WndClsEx.cbWndExtra = 0;
WndClsEx.hIcon = LoadIcon(NULL, IDI_APPLICATION);
WndClsEx.hCursor = LoadCursor(NULL, IDC_ARROW);
WndClsEx.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
WndClsEx.lpszMenuName = NULL;
WndClsEx.lpszClassName = ClsName;
WndClsEx.hInstance = hInstance;
WndClsEx.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
//BY_HANDLE_FILE_INFORMATION handle;

// Register the application
RegisterClassEx(&WndClsEx);

hWnd = CreateWindow(ClsName,
WndName,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL);
if( !hWnd ) // If the window was not created,
return 0; // stop the application

// Display the window in hidden mode.
ShowWindow(hWnd, SW_SHOWNORMAL);
UpdateWindow(hWnd);

// Get the folder locations of the folders to be monitored using the CSIDL_XXXX values and
// store it in the identifiers list.
LPITEMIDLIST ppidl = NULL;

if(SHGetSpecialFolderLocation(hWnd, CSIDL_DRIVES , &ppidl) == S_OK)
{
SHChangeNotifyEntry shCNE;
shCNE.pidl = ppidl;
shCNE.fRecursive = TRUE;

// Returns a positive integer registration identifier (ID).
// Returns zero if out of memory or in response to invalid parameters.
l_ulSHChangeNotifyRegister = SHChangeNotifyRegister(hWnd,// Hwnd to receive notification

SHCNF_ACCEPT_INTERRUPTS | SHCNF_ACCEPT_NON_INTERRUPTS|SHCNRF_RecursiveInterrupt ,

// Events of interest - use
SHCNE_CREATE,

// Notification message to be sent when the event has occured
WM_USER_MEDIACHANGED,

// Number of entries in the pfsne array should always be 1
1,

// Array of SHChangeNotifyEntry structures that
// contain the notifications.
&shCNE);
}
else
{
// Log error in retrieving folder info of system.
}

while( GetMessage(&Msg, NULL, 0, 0) )
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}

return Msg.wParam;
}


// Window call back function
LRESULT CALLBACK WndProcedure(HWND hWnd, UINT Msg,
WPARAM wParam, LPARAM lParam)
{
switch(Msg)
{
case WM_DESTROY:

arr.Format("%d",nCount);
MessageBox(NULL,arr,"Message",MB_OK);
PostQuitMessage(WM_QUIT);
break;

case WM_USER_MEDIACHANGED:

switch(lParam)
{ case SHCNE_CREATE: //File create
if (TRUE == SHGetPathFromIDList((struct _ITEMIDLIST *)shNotifyStr->dwItem1, sourcePath))
{
nCount++; }
break;
default:
break;
}

default:
// Process the left-over messages
return DefWindowProc(hWnd, Msg, wParam, lParam);
}
return 0;
}
AnswerRe: SHChangeNotifyRegister notification Pin
David Crow2-Sep-05 8:49
David Crow2-Sep-05 8:49 
GeneralRe: SHChangeNotifyRegister notification Pin
ragavan2-Sep-05 18:39
ragavan2-Sep-05 18:39 
GeneralRe: SHChangeNotifyRegister notification Pin
David Crow6-Sep-05 2:52
David Crow6-Sep-05 2:52 
QuestionFile Search Pin
bugDanny2-Sep-05 4:14
bugDanny2-Sep-05 4:14 
AnswerRe: File Search Pin
Cedric Moonen2-Sep-05 4:24
Cedric Moonen2-Sep-05 4:24 
QuestionRe: File Search Pin
bugDanny2-Sep-05 5:06
bugDanny2-Sep-05 5:06 
AnswerRe: File Search Pin
David Crow2-Sep-05 8:54
David Crow2-Sep-05 8:54 
AnswerRe: File Search Pin
Gary R. Wheeler3-Sep-05 2:54
Gary R. Wheeler3-Sep-05 2:54 
QuestionContext Help whit several tabs fails Pin
Heyerdahl2-Sep-05 4:01
Heyerdahl2-Sep-05 4:01 
Questionsafearray access violation VBA to C++ Pin
Rimcon2-Sep-05 3:59
Rimcon2-Sep-05 3:59 
AnswerRe: safearray access violation VBA to C++ Pin
Branislav3-Sep-05 21:19
Branislav3-Sep-05 21:19 
QuestionEdit Box Style For 3D Look Pin
IndianOcean2-Sep-05 3:59
IndianOcean2-Sep-05 3:59 
AnswerRe: Edit Box Style For 3D Look Pin
PJ Arends2-Sep-05 8:42
professionalPJ Arends2-Sep-05 8:42 
GeneralRe: Edit Box Style For 3D Look Pin
IndianOcean4-Sep-05 21:45
IndianOcean4-Sep-05 21:45 
GeneralRe: Edit Box Style For 3D Look Pin
PJ Arends4-Sep-05 22:00
professionalPJ Arends4-Sep-05 22:00 
GeneralRe: Edit Box Style For 3D Look Pin
IndianOcean4-Sep-05 22:15
IndianOcean4-Sep-05 22:15 
GeneralRe: Edit Box Style For 3D Look Pin
PJ Arends4-Sep-05 22:25
professionalPJ Arends4-Sep-05 22:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.