Subj : Re: borland equivalent of #pragma pack (2) is? To : borland.public.cpp.borlandcpp From : Jeff Kish Date : Sat Feb 14 2004 08:01 pm On Fri, 13 Feb 2004 16:42:33 -0800, Bob Gonder wrote: >Jeff Kish wrote: > > >You shouldn't need to mess with the pragmas. > LMAT.H contains the definitions. > >>mmm Well. Thanks. I tried the pragma and the program still had >>problems (I was trying to use the netschedulejobenum call and >>sprintf'ing the command text out was blowing up on me.. I figured it >>was just alignment/packing or something). > >The command text is Unicode, no? (LPWSTR) >Did you convert it to plain STR before sprintfing it? >Or did you use the windows version? > > wsprintf( str, "%ls", atenum.Command ); > > I know the case was wrong.. Well here is the sprintf and code.. it blows up on the sprintf, and the data in the command looks funny when I inspect it so I figured that the alignment was off.. i tried this: sprintf( gooddata, "%8lu %.70S\n", pJob->JobId, pJob->Command ); but it blew up. then this to verify something worked (and it did but it does not get me the job command text: sprintf( gooddata, "%8lu \n", pJob->JobId ); finally this: int nSize = wcstombs(szTarget,pJob->Command,2048); This blew up also. Here is the original code with some stuff I tried in comments etc.: wchar_t Servername[256]; AT_ENUM *PointerToBuffer = NULL; AT_ENUM *pJob = NULL; DWORD PreferredMaximuLength = 8192; DWORD EntriesRead = 0; DWORD TotalEntries = 0; DWORD dwResumeHandle = 0; bool bGoForIt = true; NET_API_STATUS theStatus; DWORD index = 0; int nMessages = 0; // mbstowcs( Servername, "vectrajtk", 256 ); Servername[0] = L'\0'; while (bGoForIt) { theStatus = NetScheduleJobEnum( Servername, //Pointer to a Unicode string containing the name of the remote server on which the function is to execute. A NULL pointer or string specifies the local computer. (BYTE **) &PointerToBuffer, //On return a pointer to the return information structure is returned in the address pointed to by PointerToBuffer. The return information structure is an array of AT_ENUM data structures. PreferredMaximuLength, //Preferred maximum length, in 8-bit bytes of returned data. &EntriesRead, //Pointer to a DWORD that contains the actual enumerated element count. &TotalEntries, //Pointer to a DWORD that contains the total number of entries that could have been enumerated from the current resume position. &dwResumeHandle //Pointer to a DWORD that contains ResumeHandle, which is used to continue an job enumeration. The handle should be zero on the first call and left unchanged for subsequent calls. If ResumeHandle is NULL, then no resume handle is stored. ); if ( theStatus != ERROR_SUCCESS && theStatus != ERROR_MORE_DATA ) { char darnit[1024]; sprintf(darnit, "Doh! theStatus = %lu\n", theStatus ); MessageBox(darnit,"cant continue",MB_OK); return; } for ( pJob = PointerToBuffer, index = 0; index < EntriesRead; ++ index, ++ pJob ) { char gooddata[2024]; // sprintf( gooddata, "%8lu \n", pJob->JobId ); // sprintf( gooddata, "%8lu %.70S\n", pJob->JobId, pJob->Command ); char szTarget[2048]; memset(szTarget,0,2048); int nSize = wcstombs(szTarget,pJob->Command,2048); sprintf( gooddata, "%8lu %s\n", pJob->JobId, szTarget ); MessageBox(gooddata,"GOOD DATA.. keep on going",MB_OK); nMessages++; } if ( PointerToBuffer != NULL ) NetApiBufferFree( PointerToBuffer ); if ( theStatus == ERROR_SUCCESS ) bGoForIt = false; } if (nMessages < 1) { MessageBox("no data found","at an end here",MB_OK); return; } Jeff Kish .