problem about QueryBus(Read 5334 times)
problem about QueryBus on: December 17, 2009, 01:13:16 PM
hello everyone,

    I try to use my program to test VSPD,but when I use the function "QueryBus",and try to get information about a single port ,and I copy the program in the User manual,but when I run the program,the function "QueryBus" also return 0 and the error code is "87",means wrong parameters,can anybody tell me what's wrong? Thanks a lot!

/*code listed here*/

bool GetPortInf(char *Port)
{
   OSVERSIONINFO VersionInfo;
   HINSTANCE libInst;
   bool returnvalue = false;
   char tmpbuf[100];

   VersionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
   GetVersionEx(&VersionInfo);

   if (VersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT)
     libInst = LoadLibrary("VSPDCTL.DLL");
   else
     libInst = LoadLibrary("VSPDCTL.DLL");

   if (!libInst) return false; /* Couldn't load library */

   QueryBusFn QueryBus=(QueryBusFn)GetProcAddress(libInst, "QueryBus");
   if (QueryBus==0) return false; /* Couldn't find function */

   /********************************************/
   void      *Buffer;
   long      iSize = 1024;
   VSBUS_QUERY_EX   Query;
   PPORT_INFORMATION_EX portInfo;
            
   Query.Size = sizeof (VSBUS_QUERY_EX);
   Query.QueryType = QUERYINFO_PAIR;
   mbstowcs (Query.PortName, Port, MAX_PORTNAME_LEN);
      
   Buffer = new char [iSize];
      
   while (!QueryBus((void *)(&Query), Query.Size, Buffer, iSize))
   {
      if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
      {
         int ret=GetLastError();
         sprintf(tmpbuf,"%d",ret);
         ::MessageBox(NULL,"error!",tmpbuf,MB_OK);
         delete[] Buffer;
         return false;
      }
      else
      {
         iSize *= 2;
         delete[] Buffer;
              Buffer = new char [iSize];
      }
   }
      
   while (portInfo->NextOffset != 0)
   {
      if (portInfo->NameOffset != 0)
      {
        CString portName((PWCHAR)((ULONG)portInfo + portInfo->NameOffset));
      }      
   portInfo = (PPORT_INFORMATION_EX)((ULONG)portInfo + portInfo->NextOffset);
   }
      
   portInfo = (PPORT_INFORMATION_EX)Buffer;
   delete[] Buffer;

   FreeLibrary(libInst);
   return true;
}



Re: problem about QueryBus Reply #1 on: December 18, 2009, 09:15:46 AM
Hello,

I've just answered on your e-mail.



 

Sitemap 1 2 3 4 5