⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 getuni.cpp

📁 C#一个实例源代码
💻 CPP
字号:
#define  STRICT
#include <windows.h>
#include <stdio.h>

#define BUFFSIZE = 1000

void main( int argc, char *argv[] )
{
  DWORD cbBuff = 1000;    // Size of Buffer
  TCHAR szBuff[1000];    // Buffer to receive information
  REMOTE_NAME_INFO  * prni = (REMOTE_NAME_INFO *)   &szBuff;
  // Pointers to head of buffer
  UNIVERSAL_NAME_INFO * puni = (UNIVERSAL_NAME_INFO *) &szBuff;
  DWORD res;

  if((argc < 2) | (lstrcmp(argv[1], "/?") == 0))
  {
    printf("Syntax:  GetUni DrivePathAndFilename\n"
         "Example: GetUni U:\\WINNT\\SYSTEM32\\WSOCK32.DLL\n");
    return;
  }
  
  // Call the WNetGetUniversalName function specifying the 
  //  UNIVERSAL_NAME_INFO_LEVEL option.
  //
  printf("Call WNetGetUniversalName using UNIVERSAL_NAME_INFO_LEVEL.\n");
  if((res = WNetGetUniversalName((LPTSTR)argv[1],
   UNIVERSAL_NAME_INFO_LEVEL,
   //
   //The structure is written to this block of memory.
   //
   (LPVOID) &szBuff, 
   &cbBuff)) != NO_ERROR) 
    //
    // If the call fails, print the error; otherwise, print 
    //  the location of the share, 
    //  using the pointer to UNIVERSAL_NAME_INFO_LEVEL.
    //
    printf("Error: %ld\n\n", res); 
   
else
printf("Universal Name: \t%s\n\n", 
puni->lpUniversalName); 
  //
  // Call the WNetGetUniversalName function, 
  //  using the REMOTE_NAME_INFO_LEVEL option.
  //
  printf("Call WNetGetUniversalName using REMOTE_NAME_INFO_LEVEL.\n");
  if((res = WNetGetUniversalName((LPTSTR)argv[1], 
     REMOTE_NAME_INFO_LEVEL, 
        (LPVOID) &szBuff,    //Structure is written to this block of memory
       &cbBuff)) != NO_ERROR) 
    //
    // If the call fails, print the error; otherwise, print
    //  the location of the share, using 
    //  the pointer to REMOTE_NAME_INFO_LEVEL.
    //
    printf("Error: %ld\n", res); 
  else
    printf("Universal Name: \t%s\n" 
         "Connection Name:\t%s\n" 
       "Remaining Path: \t%s\n",
          prni->lpUniversalName, 
          prni->lpConnectionName, 
          prni->lpRemainingPath);
  return;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -