代码来源:https://www.codeproject.com/Articles/13330/Using-Dialog-Templates-to-create-an-InputBox-in-C

#include <windows.h>
#include <stdio.h> int main(int argc, char *argv[])
{
printf("DlgResToDlgTemplate v1.0 (c) <lallousx86@yahoo.com>\n\n"); if (argc < )
{
printf("usage: %s MODULE_FILE DLG_ID FILE.H\n", argv[]);
return -;
} int dlgID = atoi(argv[]); HMODULE hModule;
hModule = ::LoadLibraryEx(argv[], , LOAD_LIBRARY_AS_DATAFILE);
if (hModule == NULL)
{
printf("Could not load module '%s'\n", argv[]);
return -;
} HRSRC hrsrc = ::FindResource(hModule, (LPCTSTR) dlgID, RT_DIALOG);
if (hrsrc == NULL)
{
printf("Cannot find dialog resource with id '%d'\n", dlgID);
return -;
} HGLOBAL hglobalRsrc = ::LoadResource(hModule, hrsrc);
if (hglobalRsrc == NULL)
{
printf("Cannot load resource!\n");
return -;
} char *buf = (char *)::LockResource(hglobalRsrc);
if (buf == NULL)
{
printf("Cannot lock resource!\n");
return -;
} DWORD sz = ::SizeofResource(hModule, hrsrc); FILE *fp = fopen(argv[], "wb");
if (fp == NULL)
{
printf("Could not open '%s' for writing\n", argv[]);
return -;
} char temp[]; sprintf(temp, "static unsigned char dlg_%d[] = \n{\n\t", dlgID);
fwrite(temp, , strlen(temp), fp); sz--;
for (DWORD i=;i<=sz;i++)
{
sprintf(temp, "0x%02x", (unsigned char)(buf[i] & 0xFF));
fwrite(temp, , strlen(temp), fp); // don't append a comma if it was last byte
if (i != sz)
{
fwrite(", ", , , fp);
} if (i && (i % == ))
fwrite("\n\t", , , fp);
} strcpy(temp, "\n};\n");
fwrite(temp, , strlen(temp), fp); fclose(fp);
::FreeLibrary(hModule); printf("generated %s (%d bytes) successfully!\n", argv[], sz); return ;
}

最新文章

  1. CG_INLINE,inline 内联函数
  2. (安装linux操作系统)
  3. 转 Linux 性能优化之 IO 子系统
  4. 【翻译十七】java-并发之高性能对象
  5. Android自动化测试-Robotium(一)简介
  6. jenkins+gerrit
  7. [转]Redis实现分析
  8. 使用Topshelf 5步创建Windows 服务 z
  9. CDocument类的UpdateAllViews()成员函数
  10. Windows下MySQLroot密码破解
  11. 【ANT】构建文件build.xml
  12. js JSONP实例
  13. undefined reference to `_sbrk&#39;, `_write&#39;, `_lseek&#39;, `_read&#39;
  14. CSS3制作日历
  15. 图的连通性:有向图强连通分量-Tarjan算法
  16. Mysql删除表格之后,进行恢复
  17. java-IO流-其他流
  18. Cycle (KMP + hash)
  19. javascript 模拟日历
  20. Jmeter响应中中文乱码怎么解决

热门文章

  1. class path resource [applicationContext.xml] cannot be opened because it does not exis
  2. 小程序makePhoneCall拨打电话问题
  3. mac+react-native环境搭建
  4. Centos7.5 mysql5.7.26二进制安装方式
  5. YUM源使用阿里镜像
  6. IDEA开发初始化设置
  7. Eclipse Debug模式的开启与关闭问题简析_java - JAVA
  8. 【SaltStack官方版】—— Events&amp;Reactor系统—BEACONS
  9. iView栅格的使用
  10. 数组对象去重 reduce()