forget that lets just talk about objects

ok so in my last post i wanted to get a program to run. thanks to all who tried to help but i think i am going to move on.

so i have a new question... do i need to make an "active object" to get events that happens outside the program, such as changing the folder/file names. if so is there specific variables required to make it?
Is Vexer out there?lol

'Vexer' gave me a link but i didn't look at it very close but i just took a second look and it is something i would like to use.
http://msdn.microsoft.com/en-us/library/aa365465%28VS.85%29.aspx
1
2
3
4
5
6
7
8
9
10
BOOL WINAPI ReadDirectoryChangesW(
  __in         HANDLE hDirectory,
  __out        LPVOID lpBuffer,
  __in         DWORD nBufferLength,
  __in         BOOL bWatchSubtree,
  __in         DWORD dwNotifyFilter,
  __out_opt    LPDWORD lpBytesReturned,
  __inout_opt  LPOVERLAPPED lpOverlapped,
  __in_opt     LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine
);


this how do i get it to a point so i can use it.(remember i am a noob at windows programming)
Hi,

Have your tried googling readdirectorychangesw examples?
ofcourse, but most of what i found was other peoples broken code. still searching though...
so all i did was made a widows API app and put the function in and it gives me a bunch of errors
1
2
3
4
5
6
7

9 C:\Users\Kyle\Desktop\folderlockprog\main.cpp [Warning] `__stdcall__' attribute only applies to function types

9 C:\Users\Kyle\Desktop\folderlockprog\main.cpp `BOOL ReadDirectoryChangesW' redeclared as different kind of symbol

18 C:\Users\Kyle\Desktop\folderlockprog\main.cpp initializer expression list treated as compound expression


so i have no idea what these errors mean. anyone explain them to me please, thanks
you code?:..
yeah, whats your point?
10 C:\Users\Kyle\Desktop\folderlockprog\main.cpp expected `,' or `...' before string constant

this error shows up for this line:
LPCSTR "C:Users/Kyle/Desktop/watcher",

what do i need to change?
You need a name of the variable...

remember i am a noob at windows programming

I'd have to agree. (Just Kidding)

Also, I think Incubbus meant to ask you for your code.
Last edited on
Oh, i certainly hope so,lol? how rude would that have been!lol
"you code",... yes i code ya crazy.lol-- sorry if i miss understood...

anyway this is what i have:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#include <windows.h>

/*  Declare Windows procedure  */
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);

/*  Make the class name into a global variable  */
char szClassName[ ] = "WindowsApp";

HANDLE WINAPI CreateFile(
  LPCSTR "C:Users/Kyle/Desktop/watcher", // !!!- this is where the error occurred-!!!
  DWORD 0,
  DWORD 0,
  LPSECURITY_ATTRIBUTES NULL,
  DWORD OPEN_EXISTING,
  DWORD FILE_ATTRIBUTE_NORMAL,
  HANDLE NULL
);


//BOOL WINAPI ReadDirectoryChangesW(
//  __in         HANDLE FILE_LIST_DIRECTORY,
//  __out        PVOID lpBuffer,
//  __in         DWORD nBufferLength,
//  __in         BOOL bWatchSubtree,
//  __in         DWORD dwNotifyFilter,
//  __out_opt    PDWORD lpBytesReturned,
//  __inout_opt  LPOVERLAPPED lpOverlapped,
//  __in_opt     LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine
//);



int WINAPI WinMain (HINSTANCE hThisInstance,
                    HINSTANCE hPrevInstance,
                    LPSTR lpszArgument,
                    int nFunsterStil)

{
    HWND hwnd;               /* This is the handle for our window */
    MSG messages;            /* Here messages to the application are saved */
    WNDCLASSEX wincl;        /* Data structure for the windowclass */

    /* The Window structure */
    wincl.hInstance = hThisInstance;
    wincl.lpszClassName = szClassName;
    wincl.lpfnWndProc = WindowProcedure;      /* This function is called by windows */
    wincl.style = CS_DBLCLKS;                 /* Catch double-clicks */
    wincl.cbSize = sizeof (WNDCLASSEX);

    /* Use default icon and mouse-pointer */
    wincl.hIcon = LoadIcon (NULL, "rs.ico");
    wincl.hIconSm = LoadIcon (NULL, "rs.ico");
    wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
    wincl.lpszMenuName = NULL;                 /* No menu */
    wincl.cbClsExtra = 0;                      /* No extra bytes after the window class */
    wincl.cbWndExtra = 0;                      /* structure or the window instance */
    /* Use Windows's default color as the background of the window */
    wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;

    /* Register the window class, and if it fails quit the program */
    if (!RegisterClassEx (&wincl))
        return 0;

    /* The class is registered, let's create the program*/
    hwnd = CreateWindowEx (
           0,                   /* Extended possibilites for variation */
           szClassName,         /* Classname */
           "Windows App",       /* Title Text */
           WS_OVERLAPPEDWINDOW, /* default window */
           CW_USEDEFAULT,       /* Windows decides the position */
           CW_USEDEFAULT,       /* where the window ends up on the screen */
           544,                 /* The programs width */
           375,                 /* and height in pixels */
           HWND_DESKTOP,        /* The window is a child-window to desktop */
           NULL,                /* No menu */
           hThisInstance,       /* Program Instance handler */
           NULL                 /* No Window Creation data */
           );

    /* Make the window visible on the screen */
    ShowWindow (hwnd, nFunsterStil);

    /* Run the message loop. It will run until GetMessage() returns 0 */
    while (GetMessage (&messages, NULL, 0, 0))
    {
        /* Translate virtual-key messages into character messages */
        TranslateMessage(&messages);
        /* Send message to WindowProcedure */
        DispatchMessage(&messages);
    }

    /* The program return-value is 0 - The value that PostQuitMessage() gave */
    return messages.wParam;
}


/*  This function is called by the Windows function DispatchMessage()  */

LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    switch (message)                  /* handle the messages */
    {
        case WM_DESTROY:
            PostQuitMessage (0);       /* send a WM_QUIT to the message queue */
            break;
        default:                      /* for messages that we don't deal with */
            return DefWindowProc (hwnd, message, wParam, lParam);
    }

    return 0;
}


thats all of it::edit- do i have to make a variable containing the address i want to use and substitute it in where the error is?
Last edited on
No, you can actually omit the LPCSTR all together. There are a few other problems in your code I'd like to address.

1. This is an invalid directory:
"C:Users/Kyle/Desktop/watcher"
It should be:
"C:\\Users\\Kyle\\Desktop\\watcher"
Note the double \.

2. You cannot call a function outside of a function. Consider moving your Call to CreateFile to after your call to ShowWindow.
On windows it is an valid path string while respecting the naming convetions... (the apiĀ“s will convert it to the right version)... http://msdn.microsoft.com/en-us/library/aa365247%28v=VS.85%29.aspx
Last edited on
alright well i changed the file path anyway( just to be correct),

No, you can actually omit the LPCSTR all together.


do i need any of the data types when putting the information into the call?

EDIT:: I put null for the last value needed in the call(template) and msdn says that it can be null but it comes up with an error saying cant convert int to *void. so now what should i use?
Last edited on
I think your are misinterpreting the MSDN documentation.

Say you have a function on MSDN like this:
1
2
3
4
HWND GetDlgItem(
  __in  HWND hDlg,
  __in  int nIDDlgItem
);

This is the declaration of the function, which means that you must specify the types of the arguments(the _in or _out is just added by MSDN to help you, that must be omitted from your function call as well).

When you call the function it should look like this:
 
GetDlgItem(hWnd, 1);

Note that no variable types are included there.

So, to answer your question, no, unless you are explicitly type casting(you are not).
thanks but i got it. i was feeling so stupid once i got it,lol. errrrrrr
Topic archived. No new replies allowed.