Results 1 to 9 of 9

Thread: If you know C/C++

  1. #1

    Thread Starter
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359

    If you know C/C++

    If you know c/c++, could you take a look at this thread :
    http://www.vbforums.com/showthread.p...threadid=76121
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  2. #2
    Frenzied Member
    Join Date
    Aug 2000
    Location
    O!
    Posts
    1,177
    I just looked at the C code and it looks pretty straight forward.

    What message, if any, are you getting? Also, please post the Shell statement that you use to execute the app.

  3. #3

    Thread Starter
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    Well when I try to compile the code, I get these errors :

    Code:
    --------------------Configuration: share - Win32 Debug--------------------
    Compiling...
    share.cpp
    c:\jamie\share.cpp(28) : error C2440: '=' : cannot convert from 'void *' to 'struct share_info_50 *'
            Conversion from 'void*' to pointer to non-'void' requires an explicit cast
    Error executing cl.exe.
    
    share.exe - 1 error(s), 0 warning(s)
    If I use his piece of code :
    Code:
       malloc(cbBuffer);
       // instead of :
       pBuf = malloc(cbBuffer);
    I dont get the above error, but get this one instead :

    Code:
    --------------------Configuration: share - Win32 Debug--------------------
    Compiling...
    share.cpp
    Linking...
    share.obj : error LNK2001: unresolved external symbol __imp__NetShareAdd@16
    Debug/share.exe : fatal error LNK1120: 1 unresolved externals
    Error executing link.exe.
    
    share.exe - 2 error(s), 0 warning(s)
    And I would either stick the compiled executable into a login script, or shell it just as retVal = Shell("\\ntserver\shared\blah.exe")
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  4. #4
    Frenzied Member
    Join Date
    Aug 2000
    Location
    O!
    Posts
    1,177
    Try casting the result from malloc.
    Code:
    pBuf = (struct share_info_50*) malloc(cbBuffer);
    You need pBuf as it is the pointer to the memory area allocated by malloc.

  5. #5

    Thread Starter
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    Okay that bit worked, but im still left with the second problem :

    Code:
    --------------------Configuration: share - Win32 Debug--------------------
    Compiling...
    share.cpp
    Linking...
    share.obj : error LNK2001: unresolved external symbol __imp__NetShareAdd@16
    Debug/share.exe : fatal error LNK1120: 1 unresolved externals
    Error executing link.exe.
    
    share.exe - 2 error(s), 0 warning(s)
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  6. #6
    Hyperactive Member
    Join Date
    Jan 2000
    Location
    London
    Posts
    290
    i`d suggest making sure you are including all relevant header (.h) files!

  7. #7
    Frenzied Member
    Join Date
    Aug 2000
    Location
    O!
    Posts
    1,177
    I've done a little looking around and I have to say I'm a bit mystified. At http://msdn.microsoft.com/library/ps...api3_8yk2.htm, it says share_info_50 is defined in srvapi.h, which you have as the last include in your code. However, I searched the header file and I can't find it.

    I also saw that share_info_50 is not supported in Windows NT/2000. Will this be a problem for you?

    Don't know how much more help I can be.

  8. #8

    Thread Starter
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    As far as I can tell I am.
    I took the code as is off the microsoft website.

    And as I know very little c my bug tracking is severly hindered
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  9. #9

    Thread Starter
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    /me starts crying


    Emmmmm.
    Well its all super confusing to me anyway.

    And the fact that its not compatible with nt/2k will be a very big problem.
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width