Announcement

Collapse
No announcement yet.

calling windows c programmers

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • calling windows c programmers

    aight trying to use CreateProcess() for a remote control plugin and it's erroring up the ying yang now and it USED to work, the complied dll still works but just can't compile

    here's the code
    Code:
    		case RMCTRL_0:
    			STARTUPINFO si;
    			PROCESS_INFORMATION pi;
    
    			ZeroMemory( &si, sizeof(si) );
    			si.cb = sizeof(si);
    			ZeroMemory( &pi, sizeof(pi) );
    
    			// Start the child process. 
    			CreateProcess( NULL,  // No module name (use command line). 
    				"\"C:\\Program Files\\Winamp\\Winamp.exe\"", // Command line. 
    				NULL,             // Process handle not inheritable. 
    				NULL,             // Thread handle not inheritable. 
    				FALSE,            // Set handle inheritance to FALSE. 
    				0,                // No creation flags. 
    				NULL,             // Use parent's environment block. 
    				NULL,             // Use parent's starting directory. 
    				&si,              // Pointer to STARTUPINFO structure.
    				&pi );             // Pointer to PROCESS_INFORMATION structure.
    
    			return TRUE;
    And here's the error msg:
    Code:
    Compiling...
    Winamp.c
    c:\documents and settings\bak\desktop\remotewonder\winampplugin20\winamp.c(643) : error C2275: 'STARTUPINFO' : illegal use of this type as an expression
            c:\program files\microsoft visual studio\vc98\include\winbase.h(3818) : see declaration of 'STARTUPINFO'
    c:\documents and settings\bak\desktop\remotewonder\winampplugin20\winamp.c(643) : error C2146: syntax error : missing ';' before identifier 'si'
    c:\documents and settings\bak\desktop\remotewonder\winampplugin20\winamp.c(643) : error C2065: 'si' : undeclared identifier
    c:\documents and settings\bak\desktop\remotewonder\winampplugin20\winamp.c(644) : error C2275: 'PROCESS_INFORMATION' : illegal use of this type as an expression
            c:\program files\microsoft visual studio\vc98\include\winbase.h(234) : see declaration of 'PROCESS_INFORMATION'
    c:\documents and settings\bak\desktop\remotewonder\winampplugin20\winamp.c(644) : error C2146: syntax error : missing ';' before identifier 'pi'
    c:\documents and settings\bak\desktop\remotewonder\winampplugin20\winamp.c(644) : error C2065: 'pi' : undeclared identifier
    c:\documents and settings\bak\desktop\remotewonder\winampplugin20\winamp.c(647) : error C2224: left of '.cb' must have struct/union type
    c:\documents and settings\bak\desktop\remotewonder\winampplugin20\winamp.c(659) : warning C4133: 'function' : incompatible types - from 'int *' to 'struct _STARTUPINFOA *'
    c:\documents and settings\bak\desktop\remotewonder\winampplugin20\winamp.c(660) : warning C4133: 'function' : incompatible types - from 'int *' to 'struct _PROCESS_INFORMATION *'
    Error executing cl.exe.

    I've been reading the MSDN pages and have taken code EXACTLY off their site and it errors.

    I'm programming in VS6 on WinXP SP1

    Thanks

    1997 Jeep Wrangler Rugged Waves


    Ebay Stuff For Sale

  • #2
    i'm a retard

    forgot the { } brackets


    1997 Jeep Wrangler Rugged Waves


    Ebay Stuff For Sale

    Comment


    • #3
      Originally posted by freestyler
      i'm a retard

      forgot the { } brackets

      gets you every time
      [H]4 Life
      My next generation Front End is right on schedule.
      It will be done sometime in the next generation.
      I'm a lesbian too.
      I am for hire!

      Comment


      • #4
        yea i know, i hate stupid things like that!!


        now if i can only learn how to read and write to a dialog box i'll be all set

        1997 Jeep Wrangler Rugged Waves


        Ebay Stuff For Sale

        Comment


        • #5
          freestyler,

          for a simple read/write, try "GetDlgItemText" and "SetDlgItemText" ... Basically if you had a textbox called "IDC_TEXT1" and a string callad "lpszText" and the handle to the dialogbox was called "hWndDiag", it would look like this:

          to get the text in the textbox:
          GetDlgItemText(hWndDiag, IDC_TEXT1, lpszText, strlen(lpszText) );

          to set the text in the textbox:
          SetDlgItemText(hWndDiag, IDC_TEXT1, lpszText );

          cheers,

          GTC

          Comment


          • #6
            What program are you using to write it in? I am learning C++ currently, and have been using the GCC/G++ 3.3 compilers and Pico as my editor. Nice and clean, and I can do it from anywhere
            1993 BMW 325is - 15.2sec

            Comment


            • #7
              Originally posted by SiGmA_X
              What program are you using to write it in? I am learning C++ currently, and have been using the GCC/G++ 3.3 compilers and Pico as my editor. Nice and clean, and I can do it from anywhere
              Make it easy on yourself and learn to use the vi editor. Saves a ton of time.
              90% Done
              60W DC-DC & shutdown controller
              Via C3 800, 512mb Ram, HDD 75GB IBM Deskstar, 5.6" In dash Dcustoms LCD w/ 3m USB Touch setup
              Rockfors 400s 400W amp,2x 10" Rockford Subs, Sony CDX M730 Head unit
              All in a shiny White 2000 V6 Mustang
              Click here to visit my NEW PhotoAlbum

              Comment


              • #8
                Yeah, vi is elite But I don't want to waste the time learning it.. It's what we use at work so I should learn it tho, damnit!
                1993 BMW 325is - 15.2sec

                Comment


                • #9
                  Originally posted by GTC
                  freestyler,

                  for a simple read/write, try "GetDlgItemText" and "SetDlgItemText" ... Basically if you had a textbox called "IDC_TEXT1" and a string callad "lpszText" and the handle to the dialogbox was called "hWndDiag", it would look like this:

                  to get the text in the textbox:
                  GetDlgItemText(hWndDiag, IDC_TEXT1, lpszText, strlen(lpszText) );

                  to set the text in the textbox:
                  SetDlgItemText(hWndDiag, IDC_TEXT1, lpszText );

                  cheers,

                  GTC
                  yeah that's what i thought, must have an error elsewhere, silly windows programming

                  1997 Jeep Wrangler Rugged Waves


                  Ebay Stuff For Sale

                  Comment


                  • #10
                    ok here's what i have and it's not working:

                    Code:
                    #define BUFSIZE       80
                    #define ID_NUM_0	  1040
                    #define ID_NUM_1      1041
                    #define ID_NUM_2      1042
                    #define ID_NUM_3      1043
                    #define ID_NUM_4      1044
                    #define ID_NUM_5      1045
                    #define ID_NUM_6      1046
                    #define ID_NUM_7      1047
                    #define ID_NUM_8      1048
                    #define ID_NUM_9      1049
                    
                    FILE *fp;
                    int gFocusBoxState,gStopWatch,gResize,gVolume,gVolInc,gVer;
                    char NUM_0[BUFSIZE],NUM_1[BUFSIZE],NUM_2[BUFSIZE],NUM_3[BUFSIZE],NUM_4[BUFSIZE],NUM_5[BUFSIZE],NUM_6[BUFSIZE],NUM_7[BUFSIZE],NUM_8[BUFSIZE],NUM_9[BUFSIZE];
                    
                    ......
                    
                    	SetDlgItemText(hDlg, ID_NUM_1, NUM_1);
                    	SetDlgItemText(hDlg, ID_NUM_2, NUM_2);
                    	SetDlgItemText(hDlg, ID_NUM_3, NUM_3);
                    	SetDlgItemText(hDlg, ID_NUM_4, NUM_4);
                    	SetDlgItemText(hDlg, ID_NUM_5, NUM_5);
                    	SetDlgItemText(hDlg, ID_NUM_6, NUM_6);
                    	SetDlgItemText(hDlg, ID_NUM_7, NUM_7);
                    	SetDlgItemText(hDlg, ID_NUM_8, NUM_8);
                    	SetDlgItemText(hDlg, ID_NUM_9, NUM_9);
                    	SetDlgItemText(hDlg, ID_NUM_0, NUM_0);
                    
                    .........
                    
                    		GetDlgItemText(hDlg, ID_NUM_1, NUM_1, strlen(NUM_1));
                    		GetDlgItemText(hDlg, ID_NUM_2, NUM_2, strlen(NUM_2));
                    		GetDlgItemText(hDlg, ID_NUM_3, NUM_3, strlen(NUM_3));
                    		GetDlgItemText(hDlg, ID_NUM_4, NUM_4, strlen(NUM_4));
                    		GetDlgItemText(hDlg, ID_NUM_5, NUM_5, strlen(NUM_5));
                    		GetDlgItemText(hDlg, ID_NUM_6, NUM_6, strlen(NUM_6));
                    		GetDlgItemText(hDlg, ID_NUM_7, NUM_7, strlen(NUM_7));
                    		GetDlgItemText(hDlg, ID_NUM_8, NUM_8, strlen(NUM_8));
                    		GetDlgItemText(hDlg, ID_NUM_9, NUM_9, strlen(NUM_9));
                    		GetDlgItemText(hDlg, ID_NUM_0, NUM_0, strlen(NUM_0));

                    ID_NUM_X are "Edit" boxes on the dialog box, NUM_X are just my global vars

                    GetDlgItemText & SetDlgItemText both don't seem to be working, the ini file that gets created isn't having anything wrote to it which would come from the dialog box

                    TIA

                    1997 Jeep Wrangler Rugged Waves


                    Ebay Stuff For Sale

                    Comment


                    • #11
                      freestyler,

                      I can't comment on the .ini file since there isn't any code, but otherwise things look pretty good. However, I'd drop the strlen(x) in:

                      GetDlgItemText(hDlg, ID_NUM_1, NUM_1, strlen(NUM_1));

                      in favour of:

                      GetDlgItemText(hDlg, ID_NUM_1, NUM_1, BUFSIZE);

                      just for an optimization (why calculate stuff when you don't need to?).

                      Can you provide your code that gets the handle "hDlg" ? It's also good practice to write the code something like ...

                      HWND hDlg = NULL; /// init to null ... otherwise may contain random junk
                      hDlg = CreateDialog(hInst, lpTemplate, hWndParent, lpDialogFunc); // create ...
                      if (hDlg == NULL)
                      { ... deal with a failure, ie call GetLastError() }

                      etc, etc ...

                      The easiest way to check, is to simply step through the code line by line and see which value(s) is/are "bad" ...

                      cheers,

                      GTC

                      Comment


                      • #12
                        attached is the code that i'm working with
                        just rename it to .c
                        Attached Files

                        1997 Jeep Wrangler Rugged Waves


                        Ebay Stuff For Sale

                        Comment


                        • #13
                          with your GetDlgItemText's dont use strlen as the last paramater (because it's empty, until you actually put something in it so you're telling it the size of your storage buffer is 0 bytes), the last paramater is the maximum size of the buffer (to prevent buffer overflows), you can specify either BUFSIZE-1 or sizeof(NUM_0)-1 instead.

                          Comment

                          Working...
                          X