home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.os.ms-windows.programmer.misc
- Path: sparky!uunet!think.com!ames!purdue!yuma!sailors
- From: sailors@CS.ColoState.EDU (robert sailors)
- Subject: ProgMan crashing on DDE
- Summary: ProgMan crashes when I try to add an icon and group.
- Sender: news@yuma.ACNS.ColoState.EDU (News Account)
- Message-ID: <Nov12.192036.56085@yuma.ACNS.ColoState.EDU>
- Date: Thu, 12 Nov 1992 19:20:36 GMT
- Nntp-Posting-Host: beethoven.cs.colostate.edu
- Organization: Colorado State University, Computer Science Department
- Lines: 135
-
- I have a program that needs to just create a new group and an icon in that
- group of program manager and exit. Running on my 486 and 386 systems, it
- runs fine. As soon as I move over to a 1MB 286, the program crashes
- Program Manager saing 'PROGMAN caused a General Protection Fault in module
- PROGMAN.EXE at 0007:01A3.'
-
- Basically, it just creates a window (so we have a location for ProgMan
- to send the ACKs to (though I'm not doing much with the ACK right now),
- and sends the DDE calls to ProgMan.
-
- I'm including the entire text of the C program below (due to lack of length).
- The DDE happens in the WM_CREATE message, so you can search for that to find
- the curious bits. If anyone has any suggestions on how this could be done
- better, I'd love to hear them.
-
- Thanks,
- Sean
- ---------------------------------------8<-------------------------------------
- #include <windows.h>
- #include <string.h>
- #include <dde.h>
-
- long FAR PASCAL WindowProc(HWND, unsigned, WORD, LONG);
- int PASCAL WinMain(HANDLE, HANDLE, LPSTR, int);
-
- static char *ProgramName = "Install Icons";
- static char *ClassName = "AddIcon"; /* name for window class */
- static char S_Command[150];
-
-
- /****************************/
- /* main program procedure */
-
- int PASCAL WinMain(hInstance, hPrevInstance, lpszCmdLine, nCmdShow)
- HANDLE hInstance, hPrevInstance;
- LPSTR lpszCmdLine;
- int nCmdShow;
- {
- HWND WndHandle;
- WNDCLASS Class;
- MSG Message;
-
-
- /* only allow one instance to run */
- if (hPrevInstance)
- return(FALSE);
-
- Class.style = CS_HREDRAW | CS_VREDRAW;
- Class.lpfnWndProc = WindowProc;
- Class.cbClsExtra = 0;
- Class.cbWndExtra = 0;
- Class.hInstance = hInstance;
- Class.hIcon = LoadIcon(hInstance, "picon");
- Class.hCursor = LoadCursor(NULL, IDC_ARROW);
- Class.hbrBackground = GetStockObject(WHITE_BRUSH);
- Class.lpszMenuName = NULL;
- Class.lpszClassName = ClassName;
-
- if (!RegisterClass(&Class))
- return(FALSE);
-
- /* create comand to run */
- strcpy(S_Command, "[CreateGroup(Medical Information Systems)]"
- "[ShowGroup(Medical Information Systems,1)][AddItem(");
- lstrcat(S_Command, lpszCmdLine);
- strcat(S_Command, ",MIMS)]");
-
- /* open the window */
- if (!(WndHandle = CreateWindow(ClassName, ProgramName,
- WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL,
- hInstance, NULL))) {
- MessageBox(NULL, "Error creating window", ProgramName,
- MB_OK | MB_ICONEXCLAMATION);
- return(FALSE);
- }
- ShowWindow(WndHandle, SW_HIDE);
- UpdateWindow(WndHandle);
-
- /* get messages until it's time to go */
- while (GetMessage(&Message, NULL, 0, 0)) {
- TranslateMessage(&Message);
- DispatchMessage(&Message);
- }
-
- return(Message.wParam);
- }
-
-
- long FAR PASCAL WindowProc(hWnd, iMessage, wParam, lParam)
- HWND hWnd;
- unsigned iMessage;
- WORD wParam;
- LONG lParam;
- {
- static HWND S_ProgMan = NULL;
-
-
- switch(iMessage) {
- case WM_CREATE: {
- ATOM App = GlobalAddAtom((LPSTR) "PROGMAN");
- HANDLE Cmd = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, 100);
- LPSTR pCmd;
-
-
- if (!App || !Cmd)
- ;
- pCmd = GlobalLock(Cmd);
- lstrcpy(pCmd, S_Command);
- GlobalUnlock(Cmd);
-
- SendMessage(-1, WM_DDE_INITIATE, hWnd, MAKELPARAM(App, App));
- SendMessage(S_ProgMan, WM_DDE_EXECUTE, hWnd, MAKELPARAM(0, Cmd));
- PostMessage(S_ProgMan, WM_DDE_TERMINATE, hWnd, 0L);
- GlobalDeleteAtom(App);
- GlobalFree(Cmd);
-
- /* close the window */
- SendMessage(hWnd, WM_DESTROY, 0, 0L);
- }
- break;
-
- case WM_DDE_ACK:
- S_ProgMan = wParam;
- break;
-
- case WM_DESTROY:
- PostQuitMessage(0);
- break;
-
- default:
- return(DefWindowProc(hWnd, iMessage, wParam, lParam));
- }
-
- return(FALSE);
- }
-