Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
K

Ky Nam

@Ky Nam
About
Posts
34
Topics
14
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • How to disable Type inference for generic procedures ?
    K Ky Nam

    Hello Thought I turn off option Type inference , I still has problem

    Shared Sub Abc(Of T)(ByVal def As T)
    End Sub
    
    Shared Sub Abc(ByVal def As Object)
    End Sub
    
    Shared Sub New()
         Abc("a string") '---> this line always calls Abc(Of String)(ByVal def As String)
        'I really don't want to change existing code to Abc(CObj(""))
    End Sub
    
    Visual Basic help tutorial question

  • How to get a function pointer ?
    K Ky Nam

    I need to write this code in C++/CLI only , VS 2008 , /clr After trying C++ Interop unsuccessfully , I use p/invoke and .NET delegate

    delegate bool EnumWindowsProc(IntPtr hWnd, IntPtr lParam);

    [DllImport("user32", CharSet=CharSet::Ansi, SetLastError=true, ExactSpelling=true)] static int EnumChildWindows(IntPtr hWndParent, EnumWindowsProc^ lpEnumFunc, IntPtr lParam){}

    bool CALLBACK EnumWindowsCallback(IntPtr hWnd, IntPtr lParam){}

    void UseIt() //errors
    {
    EnumWindowsProc^ fp = gcnew EnumWindowsProc(EnumWindowsCallback);
    EnumChildWindows(Handle, fp, IntPtr::Zero);
    }

    error C3350: 'EnumWindowsProc' : a delegate constructor expects 2 argument(s) error C3867: 'EnumWindowsCallback': function call missing argument list; use '&EnumWindowsCallback' to create a pointer to member I can't understand

    Managed C++/CLI c++ dotnet com help tutorial

  • How to get a function pointer ?
    K Ky Nam

    Thank for your reply , but BOOL CALLBACK EnumWindowsCallback(HWND hWnd, LPARAM lParam){} EnumChildWindows(Handle, (WNDENUMPROC)&EnumWindowsCallback, 0); error C2276: '&' : illegal operation on bound member function expression

    Managed C++/CLI c++ dotnet com help tutorial

  • How to get a function pointer ?
    K Ky Nam

    Hi I wrote this code with /clr , EnumChildWindows is C++ Interop BOOL CALLBACK EnumWindowsCallback(HWND hWnd, LPARAM lParam){} EnumChildWindows(hwnd, EnumWindowsCallback, 0); Error error C3867: 'EnumWindowsCallback': function call missing argument list; use '&EnumWindowsCallback' to create a pointer to member How to call EnumChildWindows function not using p/invoke ? Thanks :)

    Managed C++/CLI c++ dotnet com help tutorial

  • How to pass a structure contains an array in any size ?
    K Ky Nam

    It just works :)

    Public Declare Function AdjustTokenPrivileges Lib "advapi32.dll" (ByVal tokenhandle As IntPtr, ByVal disableprivs As Boolean, ByVal Newstate As IntPtr, ByVal bufferlength As Integer, ByVal PreivousState As TokenPrivileges, ByRef Returnlength As Integer) As Boolean

    Public Class TokenPrivileges
        Inherits List(Of LUIDAndAttributes)
        Implements IDisposable
    
        Dim P As IntPtr
    
        Public Function AllocHGlobal() As IntPtr
            FreeHGlobal()
    
            P = Marshal.AllocHGlobal(Marshal.SizeOf(GetType(Integer)) + Marshal.SizeOf(GetType(LUIDAndAttributes)) \* Count)
            Dim P2 As IntPtr = P
    
            Marshal.WriteInt32(P2, 0, Count)
            P2 = Sum(P2, Marshal.SizeOf(Count.GetType))
    
            For Each LUIDAndAttributes As LUIDAndAttributes In Me
                Marshal.StructureToPtr(LUIDAndAttributes, P2, False)
                P2 = Sum(P2, Marshal.SizeOf(LUIDAndAttributes.GetType))
            Next
    
            Return P
        End Function
    
        Public Sub FreeHGlobal()
            If P <> IntPtr.Zero Then
                Marshal.FreeHGlobal(P)
                P = IntPtr.Zero
            End If
        End Sub
    
    End Class
    
    Public Shared Function Sum(ByVal P As IntPtr, ByVal I As Integer) As IntPtr
        If IntPtr.Size = 4 Then
            Return New IntPtr(P.ToInt32 + I)
        Else
            Return New IntPtr(P.ToInt64 + I)
        End If
    End Function
    
    Visual Basic csharp data-structures tutorial question

  • How to pass a structure contains an array in any size ?
    K Ky Nam

    Thank you for your reply I have used this structure for years , but I just want to know how to declare it like C++ Now I'm using this approach

    Public Class SePrivilege
        Public Const SeCount As Integer = 35
        Public Const SeCreateTokenPrivilege As String = "SeCreateTokenPrivilege"
        Public Const SeAssignPrimaryTokenPrivilege As String = "SeAssignPrimaryTokenPrivilege"
        Public Const SeLockMemoryPrivilege As String = "SeLockMemoryPrivilege"
        Public Const SeIncreaseQuotaPrivilege As String = "SeIncreaseQuotaPrivilege"
        Public Const SeUnsolicitedInputPrivilege As String = "SeUnsolicitedInputPrivilege"
        Public Const SeMachineAccountPrivilege As String = "SeMachineAccountPrivilege"
        Public Const SeTcbPrivilege As String = "SeTcbPrivilege"
        Public Const SeSecurityPrivilege As String = "SeSecurityPrivilege"
        Public Const SeTakeOwnershipPrivilege As String = "SeTakeOwnershipPrivilege"
        Public Const SeLoadDriverPrivilege As String = "SeLoadDriverPrivilege"
        Public Const SeSystemProfilePrivilege As String = "SeSystemProfilePrivilege"
        Public Const SeSystemtimePrivilege As String = "SeSystemtimePrivilege"
        Public Const SeProfileSingleProcessPrivilege As String = "SeProfileSingleProcessPrivilege"
        Public Const SeIncreaseBasePriorityPrivilege As String = "SeIncreaseBasePriorityPrivilege"
        Public Const SeCreatePagefilePrivilege As String = "SeCreatePagefilePrivilege"
        Public Const SeCreatePermanentPrivilege As String = "SeCreatePermanentPrivilege"
        Public Const SeBackupPrivilege As String = "SeBackupPrivilege"
        Public Const SeRestorePrivilege As String = "SeRestorePrivilege"
        Public Const SeShutdownPrivilege As String = "SeShutdownPrivilege"
        Public Const SeDebugPrivilege As String = "SeDebugPrivilege"
        Public Const SeAuditPrivilege As String = "SeAuditPrivilege"
        Public Const SeSystemEnvironmentPrivilege As String = "SeSystemEnvironmentPrivilege"
        Public Const SeChangeNotifyPrivilege As String = "SeChangeNotifyPrivilege"
        Public Const SeRemoteShutdownPrivilege As String = "SeRemoteShutdownPrivilege"
        Public Const SeUndockPrivilege As String = "SeUndockPrivilege"
        Public Const SeSyncAgentPrivilege As String = "SeSyncAgentPrivilege"
        Public Const SeEnableDelegationPrivilege As String = "SeEnableDelegationPrivilege"
        Public Const SeManageVolumePrivilege As String = "SeManageVolumePrivilege
    
    Visual Basic csharp data-structures tutorial question

  • How to pass a structure contains an array in any size ?
    K Ky Nam

    Hi I want to use this structure in AdjustTokenPrivileges(...)

    typedef struct _TOKEN_PRIVILEGES {
    DWORD PrivilegeCount;
    LUID_AND_ATTRIBUTES Privileges[ANYSIZE_ARRAY];
    } TOKEN_PRIVILEGES, *PTOKEN_PRIVILEGES;

    How to declare it in .NET ?

    Visual Basic csharp data-structures tutorial question

  • Convert binary string to integer
    K Ky Nam

    Convert.ToInt32("10100101", 2) -> 165

    Visual Basic question csharp tutorial

  • The designer cannot create an instance of type declared as abstract.
    K Ky Nam

    Hi I created these classes :

    MustInherit Class DataTableManager
    Inherits UserControl
    End Class

    Class OrderManager
    Inherits DataTableManager
    End Class

    When I open OrderManager in designer , I get : Warning - The designer must create an instance of type 'DataTableManager' but it cannot because the type is declared as abstract. Is there any way to open OrderManager in designer ?

    Visual Basic question

  • How to change the owner of a registry key ?
    K Ky Nam

    Hi I want to open a registry key for changing the owner , user has admin right

        Dim User As String = Environment.UserDomainName & "\\" & Environment.UserName
    
        Dim K As Microsoft.Win32.RegistryKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Component Based Servicing", RegistryKeyPermissionCheck.Default, Security.AccessControl.RegistryRights.TakeOwnership)
    
        Dim RS As Security.AccessControl.RegistrySecurity = K.GetAccessControl
    
        Dim NTA As New Security.Principal.NTAccount(User)
    
        RS.SetOwner(NTA)
    
        K.SetAccessControl(RS)
    

    But .NET throws an exception : Requested registry access is not allowed I can open Regedit.exe and take registry key's owner ship , why this code doesn't work ?

    Visual Basic csharp windows-admin security tutorial question

  • How to browse class's fields in property grid ?
    K Ky Nam

    Class Class1 Public Field1 as Integer End Class I'm sure that many coders want browse Class1.Field1 in designer property grid , why Microsoft doesn't support it ?

    Visual Basic css tutorial question

  • How to tests whether the current user is a member of the Administrator's group ?
    K Ky Nam

    Thank you

    Visual Basic json tutorial question announcement

  • How to tests whether the current user is a member of the Administrator's group ?
    K Ky Nam

    I currently use IsUserAnAdmin() api function , MSDN : Minimum DLL Version shell32.dll version 5.0 or later Custom Implementation No Header shlobj.h Import library shell32.lib Minimum operating systems Windows 2000 But many users reported this function doesn't exist in Windows 2000 How to tests whether the current user is an admin ? Thank you

    Visual Basic json tutorial question announcement

  • How to send message contain a string ?
    K Ky Nam

    Thank you again :)

    Visual Basic c++ help tutorial question

  • How to send message contain a string ?
    K Ky Nam

    Thank you , i will try to write "more code"

    Visual Basic c++ help tutorial question

  • How to send message contain a string ?
    K Ky Nam

    In managed code , i send a message to native application : Dim s As String = "text that i want to send" Dim GC As GCHandle = GCHandle.Alloc(s) SendMessage( hwnd , MsgId , wParam , GC ) GC.Free() In native code , i want to display a message box with text got from above message : LRESULT WndProc( HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam ) { MessageBox(hWnd, (LPTSTR)lParam, L"Caption", MB_OKCANCEL | MB_ICONQUESTION | MB_APPLMODAL); } But i can not get text with : (LPTSTR)lParam Please help me to know why this code doesn't work , and how to do it ? Thank you

    Visual Basic c++ help tutorial question

  • How to disable the Close titlebar button ?
    K Ky Nam

    I will do it by disabling Close menu item in window's system menu

    Visual Basic tutorial question

  • How to disable the Close titlebar button ?
    K Ky Nam

    Thank you for your reply I don't use Form , I want to disable Close button of any window in system , using Window Style flags Among all Window Style flags , I find that the "SysMenu" flag is only flag to remove Close button ( plus system menu and other titlebar buttons ) But , I can create a Form with disabled Close button , by this way : 1. Handling WM_StyleChanging message , don't allow changing "SysMenu" style 2. Set Form.ControlBox=False This is the picture[^] And , I don't know why , when I use Spy++ to view Form's window styles , before and after disabling Close button ( using above two steps ) , Form's window styles doesn't change My question is : How to disable Close button using Window Style flags ?

    Visual Basic tutorial question

  • How to disable the Close titlebar button ?
    K Ky Nam

    I want to remove Close button only , not system menu & minimize/maximize buttons Thanks

    Visual Basic tutorial question

  • Why VS designer doesn't work with sub classes ?
    K Ky Nam

    Thank you very much , i have never known that "the designer can't get at the private class to create an instance of it" Actually , i want child class can use private fields and methods of parent class

    Visual Basic visual-studio tutorial question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups