Project1

标题: RM用DLL快速制作 [打印本页]

作者: yangff    时间: 2010-12-18 19:06
标题: RM用DLL快速制作
本帖最后由 yangff 于 2010-12-18 19:12 编辑

我们知道,要熟悉并能够使用MFC6这种世界上最2,最烂,现在好像只在中国最流行的一种语言,压力有点大。
作为一个学会了C++,Pascal,Basic,PHP,Ruby……还是不会用MGC6的愚者很想写一个DLL,怎么办呢??!
有一个叫做PowerBasic的XXXXXXX可以解决这个问题……
妈的我不写了¥……¥#%%#¥要吐血
  1. #COMPILER PBWIN 9
  2. #COMPILE DLL

  3. FUNCTION AddOne (BYVAL x AS LONG) EXPORT AS LONG

  4.     FUNCTION = x + 1

  5. END FUNCTION
复制代码
就这么简单……
完整时这样的
  1. '===============================================================================
  2. '
  3. '  Generic DLL Template for PowerBASIC for Windows
  4. '  Copyright (c) 1997-2005 PowerBASIC, Inc.
  5. '  All Rights Reserved.
  6. '
  7. '  LIBMAIN function Purpose:
  8. '
  9. '    User-defined function called by Windows each time a DLL is loaded into,
  10. '    and unloaded from, memory. In 32-bit Windows, LibMain is called each
  11. '    time a DLL is loaded by an application or process.  Your code should
  12. '    never call LibMain explicitly.
  13. '
  14. '    hInstance is the DLL instance handle.  This handle is used by the
  15. '    calling application to identify the DLL being called.  To access
  16. '    resources in the DLL, this handle will need to be stored in a global
  17. '    variable.  Use the GetModuleHandle(BYVAL 0&) to get the instance
  18. '    handle of the calling EXE.
  19. '
  20. '    fdwReason specifies a flag indicating why the DLL entry-point
  21. '    (LibMain) is being called by Windows.
  22. '
  23. '    lpvReserved specifies further aspects of the DLL initialization
  24. '    and cleanup.  If fdwReason is %DLL_PROCESS_ATTACH, lpvReserved is
  25. '    NULL (zero) for dynamic loads and non-NULL for static loads.  If
  26. '    fdwReason is %DLL_PROCESS_DETACH, lpvReserved is NULL if LibMain
  27. '    has been called by using the FreeLibrary API call and non-NULL if
  28. '    LibMain has been called during process termination.
  29. '
  30. ' Return
  31. '
  32. '    If LibMain is called with %DLL_PROCESS_ATTACH, your LibMain function
  33. '    should return a zero (0) if any part of your initialization process
  34. '    fails or a one (1) if no errors were encountered.  If a zero is
  35. '    returned, Windows will abort and unload the DLL from memory. When
  36. '    LibMain is called with any other value than %DLL_PROCESS_ATTACH, the
  37. '    return value is ignored.
  38. '
  39. '===============================================================================

  40. #COMPILER PBWIN 9
  41. #COMPILE DLL

  42. %USEMACROS = 1
  43. #INCLUDE "Win32API.inc"

  44. GLOBAL ghInstance AS DWORD


  45. '-------------------------------------------------------------------------------
  46. ' Main DLL entry point called by Windows...
  47. '
  48. FUNCTION LIBMAIN (BYVAL hInstance   AS LONG, _
  49.                   BYVAL fwdReason   AS LONG, _
  50.                   BYVAL lpvReserved AS LONG) AS LONG

  51.     SELECT CASE fwdReason

  52.     CASE %DLL_PROCESS_ATTACH
  53.         'Indicates that the DLL is being loaded by another process (a DLL
  54.         'or EXE is loading the DLL).  DLLs can use this opportunity to
  55.         'initialize any instance or global data, such as arrays.

  56.         ghInstance = hInstance

  57.         FUNCTION = 1   'success!

  58.         'FUNCTION = 0   'failure!  This will prevent the EXE from running.

  59.     CASE %DLL_PROCESS_DETACH
  60.         'Indicates that the DLL is being unloaded or detached from the
  61.         'calling application.  DLLs can take this opportunity to clean
  62.         'up all resources for all threads attached and known to the DLL.

  63.         FUNCTION = 1   'success!

  64.         'FUNCTION = 0   'failure!

  65.     CASE %DLL_THREAD_ATTACH
  66.         'Indicates that the DLL is being loaded by a new thread in the
  67.         'calling application.  DLLs can use this opportunity to
  68.         'initialize any thread local storage (TLS).

  69.         FUNCTION = 1   'success!

  70.         'FUNCTION = 0   'failure!

  71.     CASE %DLL_THREAD_DETACH
  72.         'Indicates that the thread is exiting cleanly.  If the DLL has
  73.         'allocated any thread local storage, it should be released.

  74.         FUNCTION = 1   'success!

  75.         'FUNCTION = 0   'failure!

  76.     END SELECT

  77. END FUNCTION


  78. '-------------------------------------------------------------------------------
  79. ' Examples of exported Subs and functions...
  80. '
  81. FUNCTION MyFunction1 ALIAS "MyFunction1" (BYVAL Param1 AS LONG) EXPORT AS LONG

  82.     ' code goes here
  83.     MSGBOX "MYDLL.DLL has recevied: " + STR$(Param1)
  84.     FUNCTION = 1  ' return 1 to calling program

  85. END FUNCTION


  86. SUB MySub1 ALIAS "MySub1" (BYVAL Param1 AS LONG) EXPORT

  87.     ' code goes here

  88. END SUB
复制代码
简单多了啊~
作者: 天朝坦克    时间: 2010-12-18 19:20
坚决的沙发,一年多不见YANG腐腐果然有进化成神的潜力呢
作者: 幻想乡茶农    时间: 2010-12-18 19:23
头像闪亮
作者: 偶尔杀人越货    时间: 2010-12-18 19:29
如果前后都没有那不成没图案的一元硬币了?
PS.我只知道WN没有XJJ
作者: 坂田银时    时间: 2010-12-18 19:51
你好啊   
作者: yangff    时间: 2010-12-19 10:59
好吧我承认我是来展示我的头像的……
作者: 逸豫    时间: 2010-12-19 11:19
MFC三聚氰胺贴面板
  三聚氰胺环保板,一种以刨花板为基材,表面经“三聚氰胺”(MELAMINE)专业加工处理,具耐磨,抗刻划,耐高温,易清洁,耐酸碱等优点的复合型饰板,英文简称为MFC(三聚氰胺贴面板)。MFC广泛被采用为板式家具,办公家具及厨房家具的主要用材。
我才不是来吐槽的呢- -
作者: 雪流星    时间: 2010-12-19 12:37
我是來打醬....打招呼的




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1