当前位置: 首页>>代码示例>>C++>>正文


C++ Profile::IsReady方法代码示例

本文整理汇总了C++中Profile::IsReady方法的典型用法代码示例。如果您正苦于以下问题:C++ Profile::IsReady方法的具体用法?C++ Profile::IsReady怎么用?C++ Profile::IsReady使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Profile的用法示例。


在下文中一共展示了Profile::IsReady方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Copy

void Profile::Copy ( Profile &Source ) {

   #ifdef __OS2__

      // If either profile isn't really open, return w/o doing anything at all.
      if ( !Handle || !Source.IsReady() ) {
         Log ( "Profile::Copy: Either the source or the target handle is invalid." ) ;
         return ;
      } /* endif */

      // Find out how much memory is needed to get the entire list of keys for this application.
      ULONG KeyListSize ;
      if ( !PrfQueryProfileSize ( Source.Handle, Source.QueryName(), 0, &KeyListSize ) ) {
         ERRORID Error = Sys_GetLastError ( 0 ) ;
         Log ( "Profile::Copy: Unable to query for the list of defined keys.  Status %08X.", Error ) ;
         return ;
      } /* endif */

      // Allocate memory to hold the key list.
      char *KeyList = new char [ ++KeyListSize ] ;
      if ( !KeyList ) {
         Log ( "Profile::Copy: Unable to allocate memory for the key list." ) ;
         return ;
      } /* endif */

      // Fetch the list of keys.
      if ( !PrfQueryProfileData ( Source.Handle, Source.QueryName(), 0, KeyList, &KeyListSize ) ) {
         ERRORID Error = Sys_GetLastError ( 0 ) ;
         Log ( "Profile::Copy: Unable to query for the key list.  Status %08X.", Error ) ;
         delete [] KeyList ;
         return ;
      } /* endif */

      // Scan the key list, copying the data to the new profile.
      char *Key = KeyList ;
      while ( *Key ) {
         ULONG ItemSize ;
         if ( !PrfQueryProfileSize ( Source.Handle, Source.QueryName(), Key, &ItemSize ) ) 
            break ;
         char *Item = new char [ ItemSize ] ;
         if ( !Item ) 
            break ;
         if ( !PrfQueryProfileData ( Source.Handle, Source.QueryName(), Key, Item, &ItemSize ) )  {
            delete [] Item ;
            break ;
         } /* endif */
         if ( !PrfWriteProfileData ( Handle, Name, Key, Item, ItemSize ) ) {
            delete [] Item ;
            break ;
         } /* endif */
         Key += strlen(Key) + 1 ;
      } /* endwhile */
  
      // Release the memory for the key list.
      delete [] KeyList ;

   #else // __NT__

      // We're not going to implement this one for now, as the only reason for it was
      //   to convert from MemSize 3.31's INI file to MemSize 4.00's file, and the Win32
      //   version had no version before 4.00.
      Source.QueryName ( ) ;

   #endif // __OS2__ vs __NT__

} /* endmethod */
开发者ID:OS2World,项目名称:UTIL-SYSTEM-MemSize,代码行数:66,代码来源:PROFILE.CPP


注:本文中的Profile::IsReady方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。